MCPcopy Create free account
hub / github.com/apache/impala / execute_using_impala_hs2

Function execute_using_impala_hs2

tests/performance/query_exec_functions.py:113–144  ·  view source on GitHub ↗

Executes a sql query against Impala using the hs2 interface. Args: query: Query query_config: ImpalaHS2Config Returns: ImpalaQueryResult

(query, query_config)

Source from the content-addressed store, hash-verified

111
112
113def 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
147def build_context(query, query_config):

Callers

nothing calls this directly

Calls 11

ImpalaQueryResultClass · 0.90
get_hs2_impala_cursorFunction · 0.85
timeFunction · 0.85
run_plugins_preMethod · 0.80
nowMethod · 0.80
run_plugins_postMethod · 0.80
closeMethod · 0.65
executeMethod · 0.45
get_summaryMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected