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

Method execute

tests/performance/query_executor.py:185–231  ·  view source on GitHub ↗

Execute a set of SQL statements using the given execution function, and return a result object. SQL statements can be the familiar SELECT, INSERT, DELETE, UPDATE and UPSERT DML commands as well as utilities like SET, SHOW, VERSION, etc. If plan_first is true, EXPLAIN the "explainab

(self, plan_first=False)

Source from the content-addressed store, hash-verified

183 self.exec_config.impalad = impalad
184
185 def execute(self, plan_first=False):
186 """Execute a set of SQL statements using the given execution function,
187 and return a result object. SQL statements can be the familiar SELECT, INSERT,
188 DELETE, UPDATE and UPSERT DML commands as well as utilities like SET, SHOW,
189 VERSION, etc.
190
191 If plan_first is true, EXPLAIN the "explainable" queries in the set
192 first so timing does not include the initial metadata loading
193 required for planning.
194
195 This function furnishes a query result object in self._result, for the last
196 query in the batch ONLY.
197 """
198 assert isinstance(self.query, Query)
199 orig_query_str = self.query.query_str
200 try:
201 statements = self.query.query_str.split(';')
202
203 if plan_first:
204 # Break out multiple statements in self.query
205 for stmt in statements:
206 ddl_crud_match = DDL_CRUD_PATTERN.match(stmt)
207 if not ddl_crud_match:
208 # Don't EXPLAIN this statement
209 continue
210
211 self.query.query_str = 'EXPLAIN ' + stmt + ';'
212 LOG.debug('Planning %s' % self.query.query_str)
213 self.exec_func(self.query, self.exec_config)
214
215 # Now actually execute
216 for stmt in statements:
217 self.query.query_str = stmt + ';'
218 LOG.debug('Executing %s' % self.query.query_str)
219 self._result = self.exec_func(self.query, self.exec_config)
220
221 if not self._result.success:
222 if self.exit_on_error:
223 raise RuntimeError(self._result.query_error)
224 else:
225 LOG.info("Continuing execution")
226 finally:
227 self.query.query_str = orig_query_str
228
229 # We do not need to restore the SET options we changed for the next batch
230 # (Query object) because the scheduler runs each Query on its own connection
231 # (XXX pretty strange for a performance test. :)
232
233 @property
234 def result(self):

Callers 3

execute_using_hive_hs2Function · 0.45
execute_using_impala_hs2Function · 0.45
_run_queriesMethod · 0.45

Calls 3

RuntimeErrorFunction · 0.85
matchMethod · 0.80
debugMethod · 0.45

Tested by

no test coverage detected