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

Method test_ctas

tests/metadata/test_ddl.py:1193–1248  ·  view source on GitHub ↗
(self, vector, unique_database)

Source from the content-addressed store, hash-verified

1191 client.close()
1192
1193 def test_ctas(self, vector, unique_database):
1194 enable_async_ddl = vector.get_value('enable_async_ddl_execution')
1195 client = self.create_impala_client(protocol=vector.get_value('protocol'))
1196
1197 try:
1198 # The CTAS is going to need the metadata of the source table in the
1199 # select. To avoid flakiness about metadata loading, this selects from
1200 # that source table first to get the metadata loaded.
1201 self.execute_query_expect_success(client,
1202 "select count(*) from functional_parquet.alltypes")
1203
1204 # Configure whether to use async DDL and add appropriate delays
1205 new_vector = deepcopy(vector)
1206 new_vector.get_value('exec_option')['enable_async_ddl_execution'] = enable_async_ddl
1207 create_delay = "CRS_DELAY_BEFORE_CATALOG_OP_EXEC:SLEEP@10000"
1208 insert_delay = "CRS_BEFORE_COORD_STARTS:SLEEP@2000"
1209 new_vector.get_value('exec_option')['debug_action'] = \
1210 "{0}|{1}".format(create_delay, insert_delay)
1211 dest_tbl = "{0}.ctas_test".format(unique_database)
1212 source_tbl = "functional_parquet.alltypes"
1213 ctas_stmt = 'create external table {0} as select * from {1}'.format(
1214 dest_tbl, source_tbl)
1215 exec_start = time.time()
1216 handle = self.execute_query_async_using_client(client, ctas_stmt, new_vector)
1217 exec_end = time.time()
1218 exec_time = exec_end - exec_start
1219 # The CRS_BEFORE_COORD_STARTS delay postpones the transition from PENDING
1220 # to RUNNING, so the sync case should be in PENDING state at the end of
1221 # the execute call. This means that the sync and async cases are the same.
1222 assert client.is_pending(handle)
1223
1224 # Wait for the statement to finish with a timeout of 40 seconds
1225 # (60 seconds without shortcircuit reads). There are other tests running
1226 # in parallel and ASAN can be slow, so this timeout has been bumped
1227 # substantially to avoid flakiness. The actual test case does not depend
1228 # on the statement finishing in a particular amount of time.
1229 wait_time = 40 if IS_HDFS else 60
1230 wait_start = time.time()
1231 client.wait_for_impala_state(handle, FINISHED, wait_time)
1232 wait_end = time.time()
1233 wait_time = wait_end - wait_start
1234 self.close_query_using_client(client, handle)
1235 # In sync mode:
1236 # The entire CTAS is processed in the exec step with delay. exec_time should be
1237 # more than 10 seconds.
1238 #
1239 # In async mode:
1240 # The compilation of CTAS is processed in the exec step without delay. And the
1241 # processing of the CTAS plan is in wait step with delay. The wait time should
1242 # definitely take more time than 10 seconds.
1243 if enable_async_ddl:
1244 assert(wait_time >= 10)
1245 else:
1246 assert(exec_time >= 10)
1247 finally:
1248 client.close()
1249
1250

Callers

nothing calls this directly

Calls 9

create_impala_clientMethod · 0.80
is_pendingMethod · 0.80
wait_for_impala_stateMethod · 0.80
closeMethod · 0.65
get_valueMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected