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)
| 1100 | |
| 1101 | |
| 1102 | def 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 | |
| 1125 | def populate_all_queries( |
no test coverage detected