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

Function sub_process

union/D3L/join_opendata_new.py:53–98  ·  view source on GitHub ↗
(query_tables, queue)

Source from the content-addressed store, hash-verified

51 return result
52
53def sub_process(query_tables, queue):
54 for i, table_name_with_extension in enumerate(query_tables):
55
56 table_name = os.path.splitext(table_name_with_extension)[0]
57 output_folder = "/home/wangyanzhang/d3l-main/d3l-main/examples/notebooks/join_opendata_new"
58 results_file = os.path.join(output_folder, f"{table_name}.csv")
59
60 if os.path.exists(results_file):
61 print(f"跳过查询表 {i + 1},因为结果文件已经存在:{results_file}")
62 queue.put(1) # 在队列中放入一个占位符值
63 continue
64
65
66 # 执行查询
67 results, extended_results = qe.table_query(table=dataloader.read_table(table_name=table_name),
68 aggregator=None, k=10, verbose=True)
69
70
71 # 创建一个新的 CSV 文件
72
73 # 指定输出文件夹路径
74 # output_folder = "/home/wangyanzhang/d3l-main/d3l-main/examples/notebooks/k_10_neighbours_100000_join"
75 # results_file = os.path.join(output_folder, f"results_final_{table_name}_k100000.csv")
76
77 #results_file = f"results_final_{table_name}_k100000.csv"
78 with open(results_file, mode='w', newline='') as csvfile:
79 writer = csv.writer(csvfile)
80
81 # Write the header
82 writer.writerow(['query_table', 'candidate_table', 'query_col_name', 'candidate_col_name'])
83
84 # 写入查询结果到 CSV 文件
85 for result in extended_results:
86 query_table = table_name
87 candidate_table = os.path.basename(result[0])
88
89 for x, column_info in enumerate(result[1]):
90 column_info_name = f"column_info{x+1}"
91 globals()[column_info_name] = column_info[0]
92
93 row = [f"{query_table}.csv", f"{candidate_table}.csv", column_info[0][0], column_info[0][1]]
94 writer.writerow(row)
95
96 print(f"Results for query table {i + 1} have been written to {results_file}")
97 queue.put(1)
98 queue.put((-1, "test-pid"))
99
100
101split_num = 1

Callers

nothing calls this directly

Calls 2

table_queryMethod · 0.80
read_tableMethod · 0.45

Tested by

no test coverage detected