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

Function sub_process

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

Callers

nothing calls this directly

Calls 2

table_queryMethod · 0.80
read_tableMethod · 0.45

Tested by

no test coverage detected