Executes a sql query against Impala using the hs2 interface. Args: query: Query query_config: ImpalaHS2Config Returns: ImpalaQueryResult
(query, query_config)
| 111 | |
| 112 | |
| 113 | def execute_using_impala_hs2(query, query_config): |
| 114 | """Executes a sql query against Impala using the hs2 interface. |
| 115 | |
| 116 | Args: |
| 117 | query: Query |
| 118 | query_config: ImpalaHS2Config |
| 119 | |
| 120 | Returns: |
| 121 | ImpalaQueryResult |
| 122 | """ |
| 123 | exec_result = ImpalaQueryResult(query, query_config=query_config) |
| 124 | plugin_runner = query_config.plugin_runner |
| 125 | cursor = get_hs2_impala_cursor(query_config.impalad, |
| 126 | use_kerberos=query_config.use_kerberos, |
| 127 | database=query.db) |
| 128 | if cursor is None: return exec_result |
| 129 | if plugin_runner: plugin_runner.run_plugins_pre(scope="Query") |
| 130 | try: |
| 131 | exec_result.start_time, start = datetime.now(), time() |
| 132 | cursor.execute(query.query_str) |
| 133 | exec_result.data = cursor.fetchall() |
| 134 | exec_result.time_taken = time() - start |
| 135 | exec_result.runtime_profile = cursor.get_profile() |
| 136 | exec_result.exec_summary = build_summary_table_from_thrift(cursor.get_summary()) |
| 137 | exec_result.success = True |
| 138 | except Exception as e: |
| 139 | LOG.error(str(e)) |
| 140 | exec_result.query_error = str(e) |
| 141 | finally: |
| 142 | cursor.close() |
| 143 | if plugin_runner: plugin_runner.run_plugins_post(scope="Query") |
| 144 | return exec_result |
| 145 | |
| 146 | |
| 147 | def build_context(query, query_config): |
nothing calls this directly
no test coverage detected