Run queries in non-interactive mode. Return True on success. Logs the error and returns False otherwise.
(options, query_options)
| 2135 | |
| 2136 | |
| 2137 | def execute_queries_non_interactive_mode(options, query_options): |
| 2138 | """Run queries in non-interactive mode. Return True on success. Logs the |
| 2139 | error and returns False otherwise.""" |
| 2140 | if options.query_file: |
| 2141 | # "-" here signifies input from STDIN |
| 2142 | if options.query_file == "-": |
| 2143 | query_text = sys.stdin.read() |
| 2144 | else: |
| 2145 | try: |
| 2146 | with open(options.query_file, 'r') as query_file_handle: |
| 2147 | query_text = query_file_handle.read() |
| 2148 | except Exception as e: |
| 2149 | print("Could not open file '%s': %s" % (options.query_file, e), file=sys.stderr) |
| 2150 | return False |
| 2151 | elif options.query: |
| 2152 | query_text = options.query |
| 2153 | else: |
| 2154 | return True |
| 2155 | |
| 2156 | queries = parse_query_text(query_text) |
| 2157 | with ImpalaShell(options, query_options) as shell: |
| 2158 | return (shell.execute_query_list(shell.cmdqueue) |
| 2159 | and shell.execute_query_list(queries)) |
| 2160 | |
| 2161 | |
| 2162 | def get_intro(options): |
no test coverage detected