MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / sub_process

Function sub_process

union/D3L/opendata_small_query_third.py:33–78  ·  view source on GitHub ↗
(query_tables, queue)

Source from the content-addressed store, hash-verified

31 return result
32
33def sub_process(query_tables, queue):
34 tables_to_skip = ["USA_CSV0000000000001722", "USA_CSV0000000000033169__0" , "USA_CSV0000000000035350"]
35 for i, table_name_with_extension in enumerate(query_tables):
36
37 table_name = os.path.splitext(table_name_with_extension)[0]
38 # 如果查询表在要跳过的列表中,跳过它
39 if table_name in tables_to_skip:
40 print(f"跳过查询表 {i + 1},因为它在要跳过的列表中")
41 queue.put(1) # 在队列中放入一个占位符值
42 continue
43 output_folder = "/home/wangyanzhang/d3l-main/d3l-main/examples/notebooks/opendata_small_test"
44 results_file = os.path.join(output_folder, f"{table_name}.csv")
45
46 if os.path.exists(results_file):
47 print(f"跳过查询表 {i + 1},因为结果文件已经存在:{results_file}")
48 queue.put(1) # 在队列中放入一个占位符值
49 continue
50
51
52 # 执行查询
53 results, extended_results = qe.table_query(table=dataloader.read_table(table_name=table_name),
54 aggregator=None, k=60, verbose=True)
55
56
57 # 创建一个新的 CSV 文件
58 with open(results_file, mode='w', newline='') as csvfile:
59 writer = csv.writer(csvfile)
60
61 # Write the header
62 writer.writerow(['query_table', 'candidate_table', 'query_col_name', 'candidate_col_name'])
63
64 # 写入查询结果到 CSV 文件
65 for result in extended_results:
66 query_table = table_name
67 candidate_table = os.path.basename(result[0])
68
69 for x, column_info in enumerate(result[1]):
70 column_info_name = f"column_info{x+1}"
71 globals()[column_info_name] = column_info[0]
72
73 row = [f"{query_table}.csv", f"{candidate_table}.csv", column_info[0][0], column_info[0][1]]
74 writer.writerow(row)
75
76 print(f"Results for query table {i + 1} have been written to {results_file}")
77 queue.put(1)
78 queue.put((-1, "test-pid"))
79
80if __name__ == "__main__":
81 # 记录程序开始时间

Callers

nothing calls this directly

Calls 2

table_queryMethod · 0.80
read_tableMethod · 0.45

Tested by

no test coverage detected