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

Method test_in_progress_compactions

tests/query_test/test_acid.py:286–315  ·  view source on GitHub ↗

Checks that in-progress compactions are not visible. The test mimics in-progress compactions by opening a transaction and creating a new base directory. The new base directory is empty and must not have an effect on query results until the transaction is committed.

(self, unique_database)

Source from the content-addressed store, hash-verified

284 @SkipIfHive2.acid
285 @SkipIfFS.hive
286 def test_in_progress_compactions(self, unique_database):
287 """Checks that in-progress compactions are not visible. The test mimics
288 in-progress compactions by opening a transaction and creating a new base
289 directory. The new base directory is empty and must not have an effect
290 on query results until the transaction is committed."""
291 tbl_name = "{}.{}".format(unique_database, "test_compaction")
292 self.execute_query("create table {} (i int) tblproperties"
293 "('transactional'='true',"
294 "'transactional_properties'='insert_only')".format(tbl_name))
295 self.execute_query("insert into {} values (1)".format(tbl_name))
296
297 # Create new base directory with a valid write id.
298 txn_id = self._open_txn()
299 tbl_file = self.execute_query(
300 "show files in {}".format(tbl_name)).data[0].split("\t")[0]
301 tbl_dir = tbl_file[tbl_file.find("/test-warehouse"):tbl_file.rfind("delta_")]
302 new_base_dir_with_old_write_id = tbl_dir + "base_1_v" + str(txn_id)
303 check_call(['hdfs', 'dfs', '-mkdir', '-p', new_base_dir_with_old_write_id])
304
305 # Transaction is not committed so the new empty base directory must not have
306 # any effect on query results.
307 self.execute_query("refresh {}".format(tbl_name))
308 assert len(self.execute_query("select * from {}".format(tbl_name)).data) != 0
309
310 # Transaction is committed, now the query should see the table as empty. Of course,
311 # real compactions don't remove data, but that verifies that the query reads the
312 # new directory.
313 self._commit_txn(txn_id)
314 self.execute_query("refresh {}".format(tbl_name))
315 assert len(self.execute_query("select * from {}".format(tbl_name)).data) == 0
316
317 @SkipIfHive2.acid
318 @SkipIf.not_dfs

Callers

nothing calls this directly

Calls 6

_open_txnMethod · 0.95
_commit_txnMethod · 0.95
rfindMethod · 0.80
formatMethod · 0.45
execute_queryMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected