Skip to content

Commit 8509a54

Browse files
Merge branch 'sea-migration' into sea-test-scripts
2 parents 641c09b + 19f1fae commit 8509a54

File tree

17 files changed

+1106
-47
lines changed

17 files changed

+1106
-47
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Release History
22

3+
# 4.0.4 (2025-06-16)
4+
5+
- Update thrift client library after cleaning up unused fields and structs (databricks/databricks-sql-python#553 by @vikrantpuppala)
6+
- Refactor decimal conversion in PyArrow tables to use direct casting (databricks/databricks-sql-python#544 by @jayantsing-db)
7+
- Fix: `fetchall_arrow` to always return results in `arrow` format (databricks/databricks-sql-python#551 by @shivam2680)
8+
- Enhance cursor close handling and context manager exception management to prevent server side resource leaks (databricks/databricks-sql-python#554 by @madhav-db)
9+
- Added additional logging to enhance debugging (databricks/databricks-sql-python#556 by @saishreeeee)
10+
- Feature: Added support for complex data types such as Arrays and Map [Private Preview] (databricks/databricks-sql-python#559 by @jprakash-db)
11+
312
# 4.0.3 (2025-04-22)
413

514
- Fix: Removed `packaging` dependency in favour of default libraries, for `urllib3` version checks (databricks/databricks-sql-python#547 by @jprakash-db)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "databricks-sql-connector"
3-
version = "4.0.3"
3+
version = "4.0.4"
44
description = "Databricks SQL Connector for Python"
55
authors = ["Databricks <databricks-sql-connector-maintainers@databricks.com>"]
66
license = "Apache-2.0"

src/databricks/sql/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __repr__(self):
6868
DATE = DBAPITypeObject("date")
6969
ROWID = DBAPITypeObject()
7070

71-
__version__ = "4.0.3"
71+
__version__ = "4.0.4"
7272
USER_AGENT_NAME = "PyDatabricksSqlConnector"
7373

7474
# These two functions are pyhive legacy

src/databricks/sql/backend/sea/models/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,49 @@
44
This package contains data models for SEA API requests and responses.
55
"""
66

7+
from databricks.sql.backend.sea.models.base import (
8+
ServiceError,
9+
StatementStatus,
10+
ExternalLink,
11+
ResultData,
12+
ColumnInfo,
13+
ResultManifest,
14+
)
15+
716
from databricks.sql.backend.sea.models.requests import (
17+
StatementParameter,
18+
ExecuteStatementRequest,
19+
GetStatementRequest,
20+
CancelStatementRequest,
21+
CloseStatementRequest,
822
CreateSessionRequest,
923
DeleteSessionRequest,
1024
)
1125

1226
from databricks.sql.backend.sea.models.responses import (
27+
ExecuteStatementResponse,
28+
GetStatementResponse,
1329
CreateSessionResponse,
1430
)
1531

1632
__all__ = [
33+
# Base models
34+
"ServiceError",
35+
"StatementStatus",
36+
"ExternalLink",
37+
"ResultData",
38+
"ColumnInfo",
39+
"ResultManifest",
1740
# Request models
41+
"StatementParameter",
42+
"ExecuteStatementRequest",
43+
"GetStatementRequest",
44+
"CancelStatementRequest",
45+
"CloseStatementRequest",
1846
"CreateSessionRequest",
1947
"DeleteSessionRequest",
2048
# Response models
49+
"ExecuteStatementResponse",
50+
"GetStatementResponse",
2151
"CreateSessionResponse",
2252
]
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
"""
2+
Base models for the SEA (Statement Execution API) backend.
3+
4+
These models define the common structures used in SEA API requests and responses.
5+
"""
6+
7+
from typing import Dict, List, Any, Optional, Union
8+
from dataclasses import dataclass, field
9+
10+
from databricks.sql.backend.types import CommandState
11+
12+
13+
@dataclass
14+
class ServiceError:
15+
"""Error information returned by the SEA API."""
16+
17+
message: str
18+
error_code: Optional[str] = None
19+
20+
21+
@dataclass
22+
class StatementStatus:
23+
"""Status information for a statement execution."""
24+
25+
state: CommandState
26+
error: Optional[ServiceError] = None
27+
sql_state: Optional[str] = None
28+
29+
30+
@dataclass
31+
class ExternalLink:
32+
"""External link information for result data."""
33+
34+
external_link: str
35+
expiration: str
36+
chunk_index: int
37+
byte_count: int = 0
38+
row_count: int = 0
39+
row_offset: int = 0
40+
next_chunk_index: Optional[int] = None
41+
next_chunk_internal_link: Optional[str] = None
42+
http_headers: Optional[Dict[str, str]] = None
43+
44+
45+
@dataclass
46+
class ChunkInfo:
47+
"""Information about a chunk in the result set."""
48+
49+
chunk_index: int
50+
byte_count: int
51+
row_offset: int
52+
row_count: int
53+
54+
55+
@dataclass
56+
class ResultData:
57+
"""Result data from a statement execution."""
58+
59+
data: Optional[List[List[Any]]] = None
60+
external_links: Optional[List[ExternalLink]] = None
61+
byte_count: Optional[int] = None
62+
chunk_index: Optional[int] = None
63+
next_chunk_index: Optional[int] = None
64+
next_chunk_internal_link: Optional[str] = None
65+
row_count: Optional[int] = None
66+
row_offset: Optional[int] = None
67+
attachment: Optional[bytes] = None
68+
69+
70+
@dataclass
71+
class ColumnInfo:
72+
"""Information about a column in the result set."""
73+
74+
name: str
75+
type_name: str
76+
type_text: str
77+
nullable: bool = True
78+
precision: Optional[int] = None
79+
scale: Optional[int] = None
80+
ordinal_position: Optional[int] = None
81+
82+
83+
@dataclass
84+
class ResultManifest:
85+
"""Manifest information for a result set."""
86+
87+
format: str
88+
schema: Dict[str, Any] # Will contain column information
89+
total_row_count: int
90+
total_byte_count: int
91+
total_chunk_count: int
92+
truncated: bool = False
93+
chunks: Optional[List[ChunkInfo]] = None
94+
result_compression: Optional[str] = None
95+
is_volume_operation: Optional[bool] = None

src/databricks/sql/backend/sea/models/requests.py

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,99 @@
1-
from typing import Dict, Any, Optional
2-
from dataclasses import dataclass
1+
"""
2+
Request models for the SEA (Statement Execution API) backend.
3+
4+
These models define the structures used in SEA API requests.
5+
"""
6+
7+
from typing import Dict, List, Any, Optional, Union
8+
from dataclasses import dataclass, field
9+
10+
11+
@dataclass
12+
class StatementParameter:
13+
"""Representation of a parameter for a SQL statement."""
14+
15+
name: str
16+
value: Optional[str] = None
17+
type: Optional[str] = None
18+
19+
20+
@dataclass
21+
class ExecuteStatementRequest:
22+
"""Representation of a request to execute a SQL statement."""
23+
24+
session_id: str
25+
statement: str
26+
warehouse_id: str
27+
disposition: str = "EXTERNAL_LINKS"
28+
format: str = "JSON_ARRAY"
29+
result_compression: Optional[str] = None
30+
parameters: Optional[List[StatementParameter]] = None
31+
wait_timeout: str = "10s"
32+
on_wait_timeout: str = "CONTINUE"
33+
row_limit: Optional[int] = None
34+
35+
def to_dict(self) -> Dict[str, Any]:
36+
"""Convert the request to a dictionary for JSON serialization."""
37+
result: Dict[str, Any] = {
38+
"warehouse_id": self.warehouse_id,
39+
"session_id": self.session_id,
40+
"statement": self.statement,
41+
"disposition": self.disposition,
42+
"format": self.format,
43+
"wait_timeout": self.wait_timeout,
44+
"on_wait_timeout": self.on_wait_timeout,
45+
}
46+
47+
if self.row_limit is not None and self.row_limit > 0:
48+
result["row_limit"] = self.row_limit
49+
50+
if self.result_compression:
51+
result["result_compression"] = self.result_compression
52+
53+
if self.parameters:
54+
result["parameters"] = [
55+
{
56+
"name": param.name,
57+
**({"value": param.value} if param.value is not None else {}),
58+
**({"type": param.type} if param.type is not None else {}),
59+
}
60+
for param in self.parameters
61+
]
62+
63+
return result
64+
65+
66+
@dataclass
67+
class GetStatementRequest:
68+
"""Representation of a request to get information about a statement."""
69+
70+
statement_id: str
71+
72+
def to_dict(self) -> Dict[str, Any]:
73+
"""Convert the request to a dictionary for JSON serialization."""
74+
return {"statement_id": self.statement_id}
75+
76+
77+
@dataclass
78+
class CancelStatementRequest:
79+
"""Representation of a request to cancel a statement."""
80+
81+
statement_id: str
82+
83+
def to_dict(self) -> Dict[str, Any]:
84+
"""Convert the request to a dictionary for JSON serialization."""
85+
return {"statement_id": self.statement_id}
86+
87+
88+
@dataclass
89+
class CloseStatementRequest:
90+
"""Representation of a request to close a statement."""
91+
92+
statement_id: str
93+
94+
def to_dict(self) -> Dict[str, Any]:
95+
"""Convert the request to a dictionary for JSON serialization."""
96+
return {"statement_id": self.statement_id}
397

498

599
@dataclass

0 commit comments

Comments
 (0)