Skip to content

Commit edb9d87

Browse files
committed
check
1 parent 3ce5083 commit edb9d87

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/databricks/sql/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ def read(self) -> Optional[OAuthToken]:
223223
self.port = kwargs.get("_port", 443)
224224
self.disable_pandas = kwargs.get("_disable_pandas", False)
225225
self.lz4_compression = kwargs.get("enable_query_result_lz4_compression", True)
226-
226+
self.staging_allowed_local_path = kwargs.get("staging_allowed_local_path", None)
227+
227228
auth_provider = get_python_sql_connector_auth_provider(
228229
server_hostname, **kwargs
229230
)
@@ -1254,6 +1255,7 @@ def __init__(
12541255
self._arrow_schema_bytes = execute_response.arrow_schema_bytes
12551256
self._next_row_index = 0
12561257
self._use_cloud_fetch = use_cloud_fetch
1258+
self.is_staging_operation = execute_response.is_staging_operation
12571259

12581260
if execute_response.arrow_queue:
12591261
# In this case the server has taken the fast path and returned an initial batch of

src/databricks/sql/volume/volume_client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,23 @@ def __init__(self, conn):
1515
:param conn: Connection object to Databricks.
1616
"""
1717
self.conn = conn
18+
19+
def is_staging_operation_allowed(self, condition) -> bool:
20+
if not condition:
21+
raise ValueError("Staging operation is not allowed")
1822

1923
def get_object(
2024
self, catalog: str, schema: str, volume: str, object_path: str, local_path: str
2125
) -> bool:
2226
get_object_query = StringUtil.create_get_object_query(
2327
catalog, schema, volume, object_path, local_path
2428
)
25-
return True
29+
30+
with self.conn.cursor() as cursor:
31+
cursor.execute(get_object_query)
32+
self.is_staging_operation_allowed(cursor.active_result_set.is_staging_operation)
33+
volume_processor = VolumeProcessor(local_path=local_path)
34+
return True
2635

2736
def get_object(
2837
self, catalog: str, schema: str, volume: str, object_path: str
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from databricks.sql import Connection
2+
3+
class VolumeProcessor:
4+
def __init__(self, **kwargs):
5+
self.connection = kwargs.get("connection")
6+
self.local_path = kwargs.get("local_path")
7+
self.input_stream = kwargs.get("input_stream")
8+
self.content_length = kwargs.get("content_length")
9+
self.abs_staging_allowed_local_paths = self.get_abs_staging_allowed_local_paths(kwargs.get("staging_allowed_local_path"))
10+
11+
def process_volume(self, catalog: str, schema: str, volume: str):
12+
pass

0 commit comments

Comments
 (0)