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

Function sub_process

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

Callers

nothing calls this directly

Calls 2

table_queryMethod · 0.80
read_tableMethod · 0.45

Tested by

no test coverage detected