Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fix inline parameters (`use_inline_params=True`) so a sequence directly after `IN` renders as a list again: `x IN %(ids)s` renders as `x IN (1,2,3)` instead of `x IN ARRAY(1,2,3)`, which Spark rejects. Inside the list, tuples render as rows for a multi-column `IN`, and a `set` or `frozenset` is accepted again. Sequences anywhere else still render as `ARRAY(...)` ([#629](https://github.com/databricks/databricks-sql-python/issues/629))
- Speed up Thrift response handling: read replies in 1 MiB chunks and decode them with Thrift's C-accelerated protocol, and stop stringifying every request/response for the default no-op debug logger. Wide result schemas, metadata calls with many rows, and inline Arrow results benefit most.
- Report `cursor.rowcount` after asynchronous DML completes on both the Thrift and kernel backends, preserving zero counts and fetched result rows.
- Correct explicit `DecimalParameter` precision and scale ordering and honor a declared zero scale. Callers that followed the previously reversed parameter descriptions must use `precision` for total digits and `scale` for fractional digits. Explicit zero precision is now sent as declared instead of silently using automatic sizing.

# 4.9.0 (2026-11-04)
- Upgrade Databricks SQL Kernel to 1.4.0, which keeps Lakehouse Real-Time session affinity and flushes shared telemetry only after the final session closes.
Expand Down
8 changes: 4 additions & 4 deletions src/databricks/sql/parameters/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,9 @@ def __init__(

The `name` argument to this function would be `my_param`.
:scale:
The maximum precision (total number of digits) of the number between 1 and 38.
The number of digits to the right of the decimal point, from 0 to precision.
:precision:
The number of digits to the right of the decimal point.
The maximum precision (total number of digits) of the number between 1 and 38.
"""
self.value: decimal.Decimal = value
self.name = name
Expand All @@ -638,8 +638,8 @@ def valid_scale_and_precision(self):
return False

def _cast_expr(self):
if self.scale and self.precision:
return self.CAST_EXPR.format(self.scale, self.precision)
if self.scale is not None and self.precision is not None:
return self.CAST_EXPR.format(self.precision, self.scale)
else:
return self.calculate_decimal_cast_string(self.value)

Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ def test_calculate_decimal_cast_string(value, expected):
assert p._cast_expr() == expected


@pytest.mark.parametrize(
"value,precision,scale,expected",
(
(Decimal("123.45"), 10, 2, "DECIMAL(10,2)"),
(Decimal("123"), 10, 0, "DECIMAL(10,0)"),
(Decimal("123.45"), None, None, "DECIMAL(5,2)"),
),
)
def test_decimal_parameter_explicit_type(value, precision, scale, expected):
parameter = DecimalParameter(value, precision=precision, scale=scale)
bound = parameter.as_tspark_param(named=False)
assert bound.type == expected
assert bound.value.stringValue == str(value)


class Primitive(Enum):
"""These are the inferrable types. This Enum is used for parametrized tests."""

Expand Down