Skip to content

Commit 2f522cc

Browse files
committed
fixes
1 parent e7abcfe commit 2f522cc

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

src/query_farm_server_base/duckdb_serialized_expression.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,27 @@ def interpret_decimal(value: dict[str, Any]) -> Decimal:
6565
type_info = value["type"]["type_info"]
6666
scale = type_info["scale"]
6767
v = value["value"]
68-
if not isinstance(v, int):
69-
breakpoint()
70-
return Decimal(v) / Decimal(10) ** scale
68+
69+
if isinstance(v, dict) and "upper" in v and "lower" in v:
70+
# Combine upper and lower into a 128-bit signed integer
71+
upper = v["upper"]
72+
lower = v["lower"]
73+
74+
# Reconstruct full integer (assuming 64-bit halves)
75+
combined = (upper << 64) | lower
76+
77+
# Convert from unsigned to signed (two's complement if necessary)
78+
if upper & (1 << 63):
79+
combined -= 1 << 128
80+
81+
decimal_value = Decimal(combined)
82+
elif isinstance(v, int):
83+
# Assume it's a simple int (64-bit)
84+
decimal_value = Decimal(v)
85+
else:
86+
raise ValueError("Unsupported decimal value format")
87+
88+
return decimal_value / Decimal(10) ** scale
7189

7290

7391
def varint_get_byte_array(blob: bytes) -> tuple[list[int], bool]:

0 commit comments

Comments
 (0)