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

Function reset_databases

tests/stress/concurrent_select.py:1102–1122  ·  view source on GitHub ↗

Reset the database to the initial state. This is done by overwriting tables which don't have the _original suffix with data from tables with the _original suffix. Note: At this time we only support Kudu tables with a simple hash partitioning based on the primary key. (SHOW CREATE TABLE would

(cursor)

Source from the content-addressed store, hash-verified

1100
1101
1102def reset_databases(cursor):
1103 """Reset the database to the initial state. This is done by overwriting tables which
1104 don't have the _original suffix with data from tables with the _original suffix.
1105
1106 Note: At this time we only support Kudu tables with a simple hash partitioning based on
1107 the primary key. (SHOW CREATE TABLE would not work otherwise.)
1108 """
1109 LOG.info("Resetting {0} database".format(cursor.db_name))
1110 tables = dict((t, cursor.describe_table(t)) for t in cursor.list_table_names())
1111 for table_name in tables:
1112 if not table_name.endswith("_original"):
1113 if table_name + "_original" in tables:
1114 cursor.execute("SHOW CREATE TABLE " + table_name)
1115 create_table_command = cursor.fetchone()[0]
1116 cursor.execute("DROP TABLE {0}".format(table_name))
1117 cursor.execute(create_table_command)
1118 cursor.execute("INSERT INTO {0} SELECT * FROM {0}_original".format(table_name))
1119 cursor.execute("COMPUTE STATS {0}".format(table_name))
1120 else:
1121 LOG.debug("Table '{0}' cannot be reset because '{0}_original' does not"
1122 " exist in '{1}' database.".format(table_name, cursor.db_name))
1123
1124
1125def populate_all_queries(

Callers 1

mainFunction · 0.85

Calls 5

list_table_namesMethod · 0.80
formatMethod · 0.45
describe_tableMethod · 0.45
executeMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected