pltr-cli 0.11.0__py3-none-any.whl → 0.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pltr/__init__.py +1 -1
- pltr/cli.py +40 -0
- pltr/commands/admin.py +565 -11
- pltr/commands/aip_agents.py +333 -0
- pltr/commands/connectivity.py +309 -1
- pltr/commands/cp.py +103 -0
- pltr/commands/dataset.py +104 -4
- pltr/commands/functions.py +503 -0
- pltr/commands/language_models.py +515 -0
- pltr/commands/mediasets.py +176 -0
- pltr/commands/models.py +362 -0
- pltr/commands/ontology.py +44 -13
- pltr/commands/orchestration.py +167 -11
- pltr/commands/project.py +231 -22
- pltr/commands/resource.py +416 -17
- pltr/commands/space.py +25 -303
- pltr/commands/sql.py +54 -7
- pltr/commands/streams.py +616 -0
- pltr/commands/third_party_applications.py +82 -0
- pltr/services/admin.py +331 -3
- pltr/services/aip_agents.py +147 -0
- pltr/services/base.py +104 -1
- pltr/services/connectivity.py +139 -0
- pltr/services/copy.py +391 -0
- pltr/services/dataset.py +77 -4
- pltr/services/folder.py +6 -1
- pltr/services/functions.py +223 -0
- pltr/services/language_models.py +281 -0
- pltr/services/mediasets.py +144 -9
- pltr/services/models.py +179 -0
- pltr/services/ontology.py +48 -1
- pltr/services/orchestration.py +133 -1
- pltr/services/project.py +213 -39
- pltr/services/resource.py +229 -60
- pltr/services/space.py +24 -175
- pltr/services/sql.py +44 -20
- pltr/services/streams.py +290 -0
- pltr/services/third_party_applications.py +53 -0
- pltr/utils/formatting.py +195 -1
- pltr/utils/pagination.py +325 -0
- {pltr_cli-0.11.0.dist-info → pltr_cli-0.13.0.dist-info}/METADATA +55 -4
- pltr_cli-0.13.0.dist-info/RECORD +70 -0
- {pltr_cli-0.11.0.dist-info → pltr_cli-0.13.0.dist-info}/WHEEL +1 -1
- pltr_cli-0.11.0.dist-info/RECORD +0 -55
- {pltr_cli-0.11.0.dist-info → pltr_cli-0.13.0.dist-info}/entry_points.txt +0 -0
- {pltr_cli-0.11.0.dist-info → pltr_cli-0.13.0.dist-info}/licenses/LICENSE +0 -0
pltr/services/space.py
CHANGED
|
@@ -17,7 +17,9 @@ class SpaceService(BaseService):
|
|
|
17
17
|
def create_space(
|
|
18
18
|
self,
|
|
19
19
|
display_name: str,
|
|
20
|
-
|
|
20
|
+
enrollment_rid: str,
|
|
21
|
+
organizations: List[str],
|
|
22
|
+
deletion_policy_organizations: List[str],
|
|
21
23
|
description: Optional[str] = None,
|
|
22
24
|
default_roles: Optional[List[str]] = None,
|
|
23
25
|
role_grants: Optional[List[Dict[str, Any]]] = None,
|
|
@@ -27,7 +29,9 @@ class SpaceService(BaseService):
|
|
|
27
29
|
|
|
28
30
|
Args:
|
|
29
31
|
display_name: Space display name
|
|
30
|
-
|
|
32
|
+
enrollment_rid: Enrollment Resource Identifier
|
|
33
|
+
organizations: List of organization RIDs
|
|
34
|
+
deletion_policy_organizations: List of organization RIDs for deletion policy
|
|
31
35
|
description: Space description (optional)
|
|
32
36
|
default_roles: List of default role names (optional)
|
|
33
37
|
role_grants: List of role grant specifications (optional)
|
|
@@ -36,21 +40,14 @@ class SpaceService(BaseService):
|
|
|
36
40
|
Created space information
|
|
37
41
|
"""
|
|
38
42
|
try:
|
|
39
|
-
# Prepare the create request payload
|
|
40
|
-
create_request: Dict[str, Any] = {
|
|
41
|
-
"display_name": display_name,
|
|
42
|
-
"organization_rid": organization_rid,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if description:
|
|
46
|
-
create_request["description"] = description
|
|
47
|
-
if default_roles:
|
|
48
|
-
create_request["default_roles"] = default_roles
|
|
49
|
-
if role_grants:
|
|
50
|
-
create_request["role_grants"] = role_grants
|
|
51
|
-
|
|
52
43
|
space = self.service.Space.create(
|
|
53
|
-
|
|
44
|
+
display_name=display_name,
|
|
45
|
+
enrollment_rid=enrollment_rid,
|
|
46
|
+
organizations=organizations,
|
|
47
|
+
deletion_policy_organizations=deletion_policy_organizations,
|
|
48
|
+
description=description,
|
|
49
|
+
default_roles=default_roles if default_roles else [],
|
|
50
|
+
role_grants=role_grants if role_grants else [],
|
|
54
51
|
preview=True,
|
|
55
52
|
)
|
|
56
53
|
return self._format_space_info(space)
|
|
@@ -115,29 +112,29 @@ class SpaceService(BaseService):
|
|
|
115
112
|
description: Optional[str] = None,
|
|
116
113
|
) -> Dict[str, Any]:
|
|
117
114
|
"""
|
|
118
|
-
Update space information.
|
|
115
|
+
Update space information using replace().
|
|
119
116
|
|
|
120
117
|
Args:
|
|
121
118
|
space_rid: Space Resource Identifier
|
|
122
|
-
display_name: New display name (optional)
|
|
119
|
+
display_name: New display name (optional, fetches current if not provided)
|
|
123
120
|
description: New description (optional)
|
|
124
121
|
|
|
125
122
|
Returns:
|
|
126
123
|
Updated space information
|
|
127
124
|
"""
|
|
128
|
-
|
|
129
|
-
if display_name:
|
|
130
|
-
update_request["display_name"] = display_name
|
|
131
|
-
if description:
|
|
132
|
-
update_request["description"] = description
|
|
133
|
-
|
|
134
|
-
if not update_request:
|
|
125
|
+
if not display_name and not description:
|
|
135
126
|
raise ValueError("At least one field must be provided for update")
|
|
136
127
|
|
|
137
128
|
try:
|
|
138
|
-
space
|
|
129
|
+
# Fetch current space to get display_name if not provided (required for replace)
|
|
130
|
+
if not display_name:
|
|
131
|
+
current_space = self.service.Space.get(space_rid, preview=True)
|
|
132
|
+
display_name = current_space.display_name
|
|
133
|
+
|
|
134
|
+
space = self.service.Space.replace(
|
|
139
135
|
space_rid=space_rid,
|
|
140
|
-
|
|
136
|
+
display_name=display_name,
|
|
137
|
+
description=description,
|
|
141
138
|
preview=True,
|
|
142
139
|
)
|
|
143
140
|
return self._format_space_info(space)
|
|
@@ -159,135 +156,6 @@ class SpaceService(BaseService):
|
|
|
159
156
|
except Exception as e:
|
|
160
157
|
raise RuntimeError(f"Failed to delete space {space_rid}: {e}")
|
|
161
158
|
|
|
162
|
-
def get_spaces_batch(self, space_rids: List[str]) -> List[Dict[str, Any]]:
|
|
163
|
-
"""
|
|
164
|
-
Get multiple spaces in a single request.
|
|
165
|
-
|
|
166
|
-
Args:
|
|
167
|
-
space_rids: List of space RIDs (max 1000)
|
|
168
|
-
|
|
169
|
-
Returns:
|
|
170
|
-
List of space information dictionaries
|
|
171
|
-
"""
|
|
172
|
-
if len(space_rids) > 1000:
|
|
173
|
-
raise ValueError("Maximum batch size is 1000 spaces")
|
|
174
|
-
|
|
175
|
-
try:
|
|
176
|
-
response = self.service.Space.get_batch(body=space_rids, preview=True)
|
|
177
|
-
spaces = []
|
|
178
|
-
for space in response.spaces:
|
|
179
|
-
spaces.append(self._format_space_info(space))
|
|
180
|
-
return spaces
|
|
181
|
-
except Exception as e:
|
|
182
|
-
raise RuntimeError(f"Failed to get spaces batch: {e}")
|
|
183
|
-
|
|
184
|
-
def get_space_members(
|
|
185
|
-
self,
|
|
186
|
-
space_rid: str,
|
|
187
|
-
principal_type: Optional[str] = None,
|
|
188
|
-
page_size: Optional[int] = None,
|
|
189
|
-
page_token: Optional[str] = None,
|
|
190
|
-
) -> List[Dict[str, Any]]:
|
|
191
|
-
"""
|
|
192
|
-
Get all members (users/groups) of a space.
|
|
193
|
-
|
|
194
|
-
Args:
|
|
195
|
-
space_rid: Space Resource Identifier
|
|
196
|
-
principal_type: Filter by principal type ('User' or 'Group', optional)
|
|
197
|
-
page_size: Number of items per page (optional)
|
|
198
|
-
page_token: Pagination token (optional)
|
|
199
|
-
|
|
200
|
-
Returns:
|
|
201
|
-
List of space member information dictionaries
|
|
202
|
-
"""
|
|
203
|
-
try:
|
|
204
|
-
members = []
|
|
205
|
-
list_params: Dict[str, Any] = {"preview": True}
|
|
206
|
-
|
|
207
|
-
if principal_type:
|
|
208
|
-
list_params["principal_type"] = principal_type
|
|
209
|
-
if page_size:
|
|
210
|
-
list_params["page_size"] = page_size
|
|
211
|
-
if page_token:
|
|
212
|
-
list_params["page_token"] = page_token
|
|
213
|
-
|
|
214
|
-
# The get_members method returns an iterator
|
|
215
|
-
for member in self.service.Space.get_members(space_rid, **list_params):
|
|
216
|
-
members.append(self._format_member_info(member))
|
|
217
|
-
return members
|
|
218
|
-
except Exception as e:
|
|
219
|
-
raise RuntimeError(f"Failed to get members for space {space_rid}: {e}")
|
|
220
|
-
|
|
221
|
-
def add_space_member(
|
|
222
|
-
self,
|
|
223
|
-
space_rid: str,
|
|
224
|
-
principal_id: str,
|
|
225
|
-
principal_type: str,
|
|
226
|
-
role_name: str,
|
|
227
|
-
) -> Dict[str, Any]:
|
|
228
|
-
"""
|
|
229
|
-
Add a member to a space with a specific role.
|
|
230
|
-
|
|
231
|
-
Args:
|
|
232
|
-
space_rid: Space Resource Identifier
|
|
233
|
-
principal_id: Principal (user/group) identifier
|
|
234
|
-
principal_type: Principal type ('User' or 'Group')
|
|
235
|
-
role_name: Role name to grant
|
|
236
|
-
|
|
237
|
-
Returns:
|
|
238
|
-
Space member information
|
|
239
|
-
"""
|
|
240
|
-
try:
|
|
241
|
-
member_request: Dict[str, Any] = {
|
|
242
|
-
"principal_id": principal_id,
|
|
243
|
-
"principal_type": principal_type,
|
|
244
|
-
"role_name": role_name,
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
result = self.service.Space.add_member(
|
|
248
|
-
space_rid=space_rid,
|
|
249
|
-
body=member_request,
|
|
250
|
-
preview=True,
|
|
251
|
-
)
|
|
252
|
-
return self._format_member_info(result)
|
|
253
|
-
except Exception as e:
|
|
254
|
-
raise RuntimeError(
|
|
255
|
-
f"Failed to add {principal_type} '{principal_id}' to space {space_rid}: {e}"
|
|
256
|
-
)
|
|
257
|
-
|
|
258
|
-
def remove_space_member(
|
|
259
|
-
self,
|
|
260
|
-
space_rid: str,
|
|
261
|
-
principal_id: str,
|
|
262
|
-
principal_type: str,
|
|
263
|
-
) -> None:
|
|
264
|
-
"""
|
|
265
|
-
Remove a member from a space.
|
|
266
|
-
|
|
267
|
-
Args:
|
|
268
|
-
space_rid: Space Resource Identifier
|
|
269
|
-
principal_id: Principal (user/group) identifier
|
|
270
|
-
principal_type: Principal type ('User' or 'Group')
|
|
271
|
-
|
|
272
|
-
Raises:
|
|
273
|
-
RuntimeError: If removal fails
|
|
274
|
-
"""
|
|
275
|
-
try:
|
|
276
|
-
member_removal: Dict[str, Any] = {
|
|
277
|
-
"principal_id": principal_id,
|
|
278
|
-
"principal_type": principal_type,
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
self.service.Space.remove_member(
|
|
282
|
-
space_rid=space_rid,
|
|
283
|
-
body=member_removal,
|
|
284
|
-
preview=True,
|
|
285
|
-
)
|
|
286
|
-
except Exception as e:
|
|
287
|
-
raise RuntimeError(
|
|
288
|
-
f"Failed to remove {principal_type} '{principal_id}' from space {space_rid}: {e}"
|
|
289
|
-
)
|
|
290
|
-
|
|
291
159
|
def _format_space_info(self, space: Any) -> Dict[str, Any]:
|
|
292
160
|
"""
|
|
293
161
|
Format space information for consistent output.
|
|
@@ -316,25 +184,6 @@ class SpaceService(BaseService):
|
|
|
316
184
|
"type": "space",
|
|
317
185
|
}
|
|
318
186
|
|
|
319
|
-
def _format_member_info(self, member: Any) -> Dict[str, Any]:
|
|
320
|
-
"""
|
|
321
|
-
Format space member information for consistent output.
|
|
322
|
-
|
|
323
|
-
Args:
|
|
324
|
-
member: Member object from Foundry SDK
|
|
325
|
-
|
|
326
|
-
Returns:
|
|
327
|
-
Formatted member information dictionary
|
|
328
|
-
"""
|
|
329
|
-
return {
|
|
330
|
-
"space_rid": getattr(member, "space_rid", None),
|
|
331
|
-
"principal_id": getattr(member, "principal_id", None),
|
|
332
|
-
"principal_type": getattr(member, "principal_type", None),
|
|
333
|
-
"role_name": getattr(member, "role_name", None),
|
|
334
|
-
"added_by": getattr(member, "added_by", None),
|
|
335
|
-
"added_time": self._format_timestamp(getattr(member, "added_time", None)),
|
|
336
|
-
}
|
|
337
|
-
|
|
338
187
|
def _format_timestamp(self, timestamp: Any) -> Optional[str]:
|
|
339
188
|
"""
|
|
340
189
|
Format timestamp for display.
|
pltr/services/sql.py
CHANGED
|
@@ -30,6 +30,7 @@ class SqlService(BaseService):
|
|
|
30
30
|
fallback_branch_ids: Optional[List[str]] = None,
|
|
31
31
|
timeout: int = 300,
|
|
32
32
|
format: str = "table",
|
|
33
|
+
preview: bool = True,
|
|
33
34
|
) -> Dict[str, Any]:
|
|
34
35
|
"""
|
|
35
36
|
Execute a SQL query and wait for completion.
|
|
@@ -39,6 +40,7 @@ class SqlService(BaseService):
|
|
|
39
40
|
fallback_branch_ids: Optional list of branch IDs for fallback
|
|
40
41
|
timeout: Maximum time to wait for query completion (seconds)
|
|
41
42
|
format: Output format for results ('table', 'json', 'raw')
|
|
43
|
+
preview: Enable preview mode (required for SQL API, defaults to True)
|
|
42
44
|
|
|
43
45
|
Returns:
|
|
44
46
|
Dictionary containing query results and metadata
|
|
@@ -49,19 +51,23 @@ class SqlService(BaseService):
|
|
|
49
51
|
try:
|
|
50
52
|
# Submit the query
|
|
51
53
|
status = self.service.execute(
|
|
52
|
-
query=query, fallback_branch_ids=fallback_branch_ids
|
|
54
|
+
query=query, fallback_branch_ids=fallback_branch_ids, preview=preview
|
|
53
55
|
)
|
|
54
56
|
|
|
55
57
|
# If the query completed immediately
|
|
56
58
|
if isinstance(status, SucceededQueryStatus):
|
|
57
|
-
return self._format_completed_query(
|
|
59
|
+
return self._format_completed_query(
|
|
60
|
+
status.query_id, format, preview=preview
|
|
61
|
+
)
|
|
58
62
|
elif isinstance(status, FailedQueryStatus):
|
|
59
63
|
raise RuntimeError(f"Query failed: {status.error_message}")
|
|
60
64
|
elif isinstance(status, CanceledQueryStatus):
|
|
61
65
|
raise RuntimeError("Query was canceled")
|
|
62
66
|
elif isinstance(status, RunningQueryStatus):
|
|
63
67
|
# Wait for completion
|
|
64
|
-
return self._wait_for_query_completion(
|
|
68
|
+
return self._wait_for_query_completion(
|
|
69
|
+
status.query_id, timeout, format, preview=preview
|
|
70
|
+
)
|
|
65
71
|
else:
|
|
66
72
|
raise RuntimeError(f"Unknown query status type: {type(status)}")
|
|
67
73
|
|
|
@@ -71,7 +77,10 @@ class SqlService(BaseService):
|
|
|
71
77
|
raise RuntimeError(f"Failed to execute query: {e}")
|
|
72
78
|
|
|
73
79
|
def submit_query(
|
|
74
|
-
self,
|
|
80
|
+
self,
|
|
81
|
+
query: str,
|
|
82
|
+
fallback_branch_ids: Optional[List[str]] = None,
|
|
83
|
+
preview: bool = True,
|
|
75
84
|
) -> Dict[str, Any]:
|
|
76
85
|
"""
|
|
77
86
|
Submit a SQL query without waiting for completion.
|
|
@@ -79,6 +88,7 @@ class SqlService(BaseService):
|
|
|
79
88
|
Args:
|
|
80
89
|
query: SQL query string
|
|
81
90
|
fallback_branch_ids: Optional list of branch IDs for fallback
|
|
91
|
+
preview: Enable preview mode (required for SQL API, defaults to True)
|
|
82
92
|
|
|
83
93
|
Returns:
|
|
84
94
|
Dictionary containing query ID and initial status
|
|
@@ -88,18 +98,19 @@ class SqlService(BaseService):
|
|
|
88
98
|
"""
|
|
89
99
|
try:
|
|
90
100
|
status = self.service.execute(
|
|
91
|
-
query=query, fallback_branch_ids=fallback_branch_ids
|
|
101
|
+
query=query, fallback_branch_ids=fallback_branch_ids, preview=preview
|
|
92
102
|
)
|
|
93
103
|
return self._format_query_status(status)
|
|
94
104
|
except Exception as e:
|
|
95
105
|
raise RuntimeError(f"Failed to submit query: {e}")
|
|
96
106
|
|
|
97
|
-
def get_query_status(self, query_id: str) -> Dict[str, Any]:
|
|
107
|
+
def get_query_status(self, query_id: str, preview: bool = True) -> Dict[str, Any]:
|
|
98
108
|
"""
|
|
99
109
|
Get the status of a submitted query.
|
|
100
110
|
|
|
101
111
|
Args:
|
|
102
112
|
query_id: Query identifier
|
|
113
|
+
preview: Enable preview mode (required for SQL API, defaults to True)
|
|
103
114
|
|
|
104
115
|
Returns:
|
|
105
116
|
Dictionary containing query status information
|
|
@@ -108,18 +119,21 @@ class SqlService(BaseService):
|
|
|
108
119
|
RuntimeError: If status check fails
|
|
109
120
|
"""
|
|
110
121
|
try:
|
|
111
|
-
status = self.service.get_status(query_id)
|
|
122
|
+
status = self.service.get_status(query_id, preview=preview)
|
|
112
123
|
return self._format_query_status(status)
|
|
113
124
|
except Exception as e:
|
|
114
125
|
raise RuntimeError(f"Failed to get query status: {e}")
|
|
115
126
|
|
|
116
|
-
def get_query_results(
|
|
127
|
+
def get_query_results(
|
|
128
|
+
self, query_id: str, format: str = "table", preview: bool = True
|
|
129
|
+
) -> Dict[str, Any]:
|
|
117
130
|
"""
|
|
118
131
|
Get the results of a completed query.
|
|
119
132
|
|
|
120
133
|
Args:
|
|
121
134
|
query_id: Query identifier
|
|
122
135
|
format: Output format ('table', 'json', 'raw')
|
|
136
|
+
preview: Enable preview mode (required for SQL API, defaults to True)
|
|
123
137
|
|
|
124
138
|
Returns:
|
|
125
139
|
Dictionary containing query results
|
|
@@ -129,7 +143,7 @@ class SqlService(BaseService):
|
|
|
129
143
|
"""
|
|
130
144
|
try:
|
|
131
145
|
# First check if the query has completed successfully
|
|
132
|
-
status = self.service.get_status(query_id)
|
|
146
|
+
status = self.service.get_status(query_id, preview=preview)
|
|
133
147
|
if not isinstance(status, SucceededQueryStatus):
|
|
134
148
|
status_info = self._format_query_status(status)
|
|
135
149
|
if isinstance(status, FailedQueryStatus):
|
|
@@ -142,7 +156,7 @@ class SqlService(BaseService):
|
|
|
142
156
|
raise RuntimeError(f"Query status: {status_info['status']}")
|
|
143
157
|
|
|
144
158
|
# Get the results
|
|
145
|
-
results_bytes = self.service.get_results(query_id)
|
|
159
|
+
results_bytes = self.service.get_results(query_id, preview=preview)
|
|
146
160
|
return self._format_query_results(results_bytes, format)
|
|
147
161
|
|
|
148
162
|
except Exception as e:
|
|
@@ -150,12 +164,13 @@ class SqlService(BaseService):
|
|
|
150
164
|
raise
|
|
151
165
|
raise RuntimeError(f"Failed to get query results: {e}")
|
|
152
166
|
|
|
153
|
-
def cancel_query(self, query_id: str) -> Dict[str, Any]:
|
|
167
|
+
def cancel_query(self, query_id: str, preview: bool = True) -> Dict[str, Any]:
|
|
154
168
|
"""
|
|
155
169
|
Cancel a running query.
|
|
156
170
|
|
|
157
171
|
Args:
|
|
158
172
|
query_id: Query identifier
|
|
173
|
+
preview: Enable preview mode (required for SQL API, defaults to True)
|
|
159
174
|
|
|
160
175
|
Returns:
|
|
161
176
|
Dictionary containing cancellation status
|
|
@@ -164,15 +179,19 @@ class SqlService(BaseService):
|
|
|
164
179
|
RuntimeError: If cancellation fails
|
|
165
180
|
"""
|
|
166
181
|
try:
|
|
167
|
-
self.service.cancel(query_id)
|
|
182
|
+
self.service.cancel(query_id, preview=preview)
|
|
168
183
|
# Get updated status after cancellation
|
|
169
|
-
status = self.service.get_status(query_id)
|
|
184
|
+
status = self.service.get_status(query_id, preview=preview)
|
|
170
185
|
return self._format_query_status(status)
|
|
171
186
|
except Exception as e:
|
|
172
187
|
raise RuntimeError(f"Failed to cancel query: {e}")
|
|
173
188
|
|
|
174
189
|
def wait_for_completion(
|
|
175
|
-
self,
|
|
190
|
+
self,
|
|
191
|
+
query_id: str,
|
|
192
|
+
timeout: int = 300,
|
|
193
|
+
poll_interval: int = 2,
|
|
194
|
+
preview: bool = True,
|
|
176
195
|
) -> Dict[str, Any]:
|
|
177
196
|
"""
|
|
178
197
|
Wait for a query to complete.
|
|
@@ -181,6 +200,7 @@ class SqlService(BaseService):
|
|
|
181
200
|
query_id: Query identifier
|
|
182
201
|
timeout: Maximum time to wait (seconds)
|
|
183
202
|
poll_interval: Time between status checks (seconds)
|
|
203
|
+
preview: Enable preview mode (required for SQL API, defaults to True)
|
|
184
204
|
|
|
185
205
|
Returns:
|
|
186
206
|
Dictionary containing final query status
|
|
@@ -192,7 +212,7 @@ class SqlService(BaseService):
|
|
|
192
212
|
|
|
193
213
|
while time.time() - start_time < timeout:
|
|
194
214
|
try:
|
|
195
|
-
status = self.service.get_status(query_id)
|
|
215
|
+
status = self.service.get_status(query_id, preview=preview)
|
|
196
216
|
|
|
197
217
|
if isinstance(status, SucceededQueryStatus):
|
|
198
218
|
return self._format_query_status(status)
|
|
@@ -216,7 +236,7 @@ class SqlService(BaseService):
|
|
|
216
236
|
raise RuntimeError(f"Query timed out after {timeout} seconds")
|
|
217
237
|
|
|
218
238
|
def _wait_for_query_completion(
|
|
219
|
-
self, query_id: str, timeout: int, format: str
|
|
239
|
+
self, query_id: str, timeout: int, format: str, preview: bool = True
|
|
220
240
|
) -> Dict[str, Any]:
|
|
221
241
|
"""
|
|
222
242
|
Wait for query completion and return formatted results.
|
|
@@ -225,28 +245,32 @@ class SqlService(BaseService):
|
|
|
225
245
|
query_id: Query identifier
|
|
226
246
|
timeout: Maximum wait time
|
|
227
247
|
format: Result format
|
|
248
|
+
preview: Enable preview mode (required for SQL API, defaults to True)
|
|
228
249
|
|
|
229
250
|
Returns:
|
|
230
251
|
Dictionary with query results
|
|
231
252
|
"""
|
|
232
253
|
# Wait for completion
|
|
233
|
-
self.wait_for_completion(query_id, timeout)
|
|
254
|
+
self.wait_for_completion(query_id, timeout, preview=preview)
|
|
234
255
|
|
|
235
256
|
# Get results
|
|
236
|
-
return self._format_completed_query(query_id, format)
|
|
257
|
+
return self._format_completed_query(query_id, format, preview=preview)
|
|
237
258
|
|
|
238
|
-
def _format_completed_query(
|
|
259
|
+
def _format_completed_query(
|
|
260
|
+
self, query_id: str, format: str, preview: bool = True
|
|
261
|
+
) -> Dict[str, Any]:
|
|
239
262
|
"""
|
|
240
263
|
Format a completed query's results.
|
|
241
264
|
|
|
242
265
|
Args:
|
|
243
266
|
query_id: Query identifier
|
|
244
267
|
format: Result format
|
|
268
|
+
preview: Enable preview mode (required for SQL API, defaults to True)
|
|
245
269
|
|
|
246
270
|
Returns:
|
|
247
271
|
Formatted query results
|
|
248
272
|
"""
|
|
249
|
-
results_bytes = self.service.get_results(query_id)
|
|
273
|
+
results_bytes = self.service.get_results(query_id, preview=preview)
|
|
250
274
|
results = self._format_query_results(results_bytes, format)
|
|
251
275
|
|
|
252
276
|
return {
|