@@ -57,9 +57,9 @@ def execute_query(self, query: str) -> list[dict[str, Any]]:
57
57
try :
58
58
result = self .session .sql (query ).to_pandas ()
59
59
result_rows = result .to_dict (orient = "records" )
60
- query_id = str (uuid .uuid4 ())
60
+ data_id = str (uuid .uuid4 ())
61
61
62
- return result_rows , query_id
62
+ return result_rows , data_id
63
63
64
64
except Exception as e :
65
65
logger .error (f'Database error executing "{ query } ": { e } ' )
@@ -113,7 +113,7 @@ async def handle_list_tables(arguments, db, *_):
113
113
FROM { db .connection_config ['database' ]} .information_schema.tables
114
114
WHERE table_schema = '{ db .connection_config ['schema' ].upper ()} '
115
115
"""
116
- results , query_id = db .execute_query (query )
116
+ results , data_id = db .execute_query (query )
117
117
return [types .TextContent (type = "text" , text = data_to_yaml (results ), artifacts = [{"type" : "dataframe" , "data" : results }])]
118
118
119
119
@@ -131,10 +131,10 @@ async def handle_describe_table(arguments, db, *_):
131
131
FROM { database_name } .information_schema.columns
132
132
WHERE table_schema = '{ schema_name } ' AND table_name = '{ table_name } '
133
133
"""
134
- results , query_id = db .execute_query (query )
134
+ results , data_id = db .execute_query (query )
135
135
return [
136
136
types .TextContent (
137
- type = "text" , text = data_to_yaml (results ), artifacts = [{"type" : "dataframe" , "data" : results , "query_id " : query_id }]
137
+ type = "text" , text = data_to_yaml (results ), artifacts = [{"type" : "dataframe" , "data" : results , "data_id " : data_id }]
138
138
)
139
139
]
140
140
@@ -144,16 +144,16 @@ async def handle_read_query(arguments, db, write_detector, *_):
144
144
if write_detector .analyze_query (arguments ["query" ])["contains_write" ]:
145
145
raise ValueError ("Calls to read_query should not contain write operations" )
146
146
147
- results , query_id = db .execute_query (arguments ["query" ])
147
+ results , data_id = db .execute_query (arguments ["query" ])
148
148
truncate = len (results ) > MAX_RESULTS
149
149
results_text = data_to_yaml (results [:MAX_RESULTS ])
150
150
if truncate :
151
151
results_text += f"\n Results of query have been truncated. There are { len (results ) - MAX_RESULTS } more rows."
152
- results_text += f"\n query_id = { query_id } "
152
+ results_text += f"\n data_id = { data_id } "
153
153
154
154
return [
155
155
types .TextContent (
156
- type = "text" , text = results_text , artifacts = [{"type" : "dataframe" , "data" : results , "query_id " : query_id }]
156
+ type = "text" , text = results_text , artifacts = [{"type" : "dataframe" , "data" : results , "data_id " : data_id }]
157
157
)
158
158
]
159
159
@@ -173,7 +173,7 @@ async def handle_write_query(arguments, db, _, allow_write, __):
173
173
if arguments ["query" ].strip ().upper ().startswith ("SELECT" ):
174
174
raise ValueError ("SELECT queries are not allowed for write_query" )
175
175
176
- results , query_id = db .execute_query (arguments ["query" ])
176
+ results , data_id = db .execute_query (arguments ["query" ])
177
177
return [types .TextContent (type = "text" , text = str (results ))]
178
178
179
179
@@ -183,21 +183,21 @@ async def handle_create_table(arguments, db, _, allow_write, __):
183
183
if not arguments ["query" ].strip ().upper ().startswith ("CREATE TABLE" ):
184
184
raise ValueError ("Only CREATE TABLE statements are allowed" )
185
185
186
- results , query_id = db .execute_query (arguments ["query" ])
187
- return [types .TextContent (type = "text" , text = f"Table created successfully. query_id = { query_id } " )]
186
+ results , data_id = db .execute_query (arguments ["query" ])
187
+ return [types .TextContent (type = "text" , text = f"Table created successfully. data_id = { data_id } " )]
188
188
189
189
190
190
async def prefetch_tables (db : SnowflakeDB , credentials : dict ) -> str :
191
191
"""Prefetch table and column information"""
192
192
try :
193
193
logger .info ("Prefetching table descriptions" )
194
- table_results , query_id = db .execute_query (
194
+ table_results , data_id = db .execute_query (
195
195
f"""SELECT table_name, comment
196
196
FROM { credentials ['database' ]} .information_schema.tables
197
197
WHERE table_schema = '{ credentials ['schema' ].upper ()} '"""
198
198
)
199
199
200
- column_results , query_id = db .execute_query (
200
+ column_results , data_id = db .execute_query (
201
201
f"""SELECT table_name, column_name, data_type, comment
202
202
FROM { credentials ['database' ]} .information_schema.columns
203
203
WHERE table_schema = '{ credentials ['schema' ].upper ()} '"""
0 commit comments