(predicted_sql, ground_truth, db_path, iterate_num)
| 38 | |
| 39 | |
| 40 | def iterated_execute_sql(predicted_sql, ground_truth, db_path, iterate_num): |
| 41 | conn = sqlite3.connect(db_path) |
| 42 | diff_list = [] |
| 43 | cursor = conn.cursor() |
| 44 | cursor.execute(predicted_sql) |
| 45 | predicted_res = cursor.fetchall() |
| 46 | cursor.execute(ground_truth) |
| 47 | ground_truth_res = cursor.fetchall() |
| 48 | time_ratio = 0 |
| 49 | if set(predicted_res) == set(ground_truth_res): |
| 50 | for i in range(iterate_num): |
| 51 | predicted_time = execute_sql(predicted_sql, db_path) |
| 52 | ground_truth_time = execute_sql(ground_truth, db_path) |
| 53 | diff_list.append(ground_truth_time / predicted_time) |
| 54 | processed_diff_list = clean_abnormal(diff_list) |
| 55 | time_ratio = sum(processed_diff_list) / len(processed_diff_list) |
| 56 | return time_ratio |
| 57 | |
| 58 | |
| 59 | def execute_model(predicted_sql, ground_truth, db_place, idx, iterate_num, meta_time_out): |
nothing calls this directly
no test coverage detected