| 55 | impala.drop_db_if_exists(target_db) |
| 56 | |
| 57 | def load_data(): |
| 58 | sql_params = { |
| 59 | "source_db_name": source_db, |
| 60 | "target_db_name": target_db, |
| 61 | "kudu_master": kudu_master, |
| 62 | "buckets": buckets} |
| 63 | |
| 64 | sql_file_path = get_test_file_path(workload) |
| 65 | with open(sql_file_path, "r") as test: |
| 66 | queries = sqlparse.split(test.read()) |
| 67 | |
| 68 | with cluster.impala.cursor() as impala: |
| 69 | impala.create_db_if_not_exists(target_db) |
| 70 | impala.execute("USE %s" % target_db) |
| 71 | for query in queries: |
| 72 | query = sqlparse.format(query.rstrip(';'), strip_comments=True) |
| 73 | query_str = query.format(**sql_params) |
| 74 | if (len(query_str)) == 0: continue |
| 75 | if verbose: print(query_str) |
| 76 | impala.execute(query_str) |
| 77 | |
| 78 | def get_test_file_path(workload): |
| 79 | if "IMPALA_HOME" not in os.environ: |