Fix: Parametrized bigdecimal mapping was being concatenated with params#7584
Fix: Parametrized bigdecimal mapping was being concatenated with params#7584themisvaltinos wants to merge 1 commit intomainfrom
Conversation
SQLGlot Integration Test ResultsComparing:
By Dialect
Overallmain: 113236 total, 112046 passed (pass rate: 98.9%), sqlglot version: sqlglot:themis/bigdec: 109169 total, 108877 passed (pass rate: 99.7%), sqlglot version: Transitions: Dialect pair changes: 0 previous results not found, 1 current results not found ✅ 38 test(s) passed |
40929f0 to
40c53cd
Compare
| if not expr_nested and isinstance(type_value, exp.DType): | ||
| expression = self.datatype_param_bound_limiter(expression, type_value) |
There was a problem hiding this comment.
datatype_sql is hot so I think we should gate this by whether the dialect has type bounds, wdyt?
| and int(param_value.to_py()) > bound | ||
| ): | ||
| self.unsupported( | ||
| f"{type_value.value} parameter ({int(param_value.to_py())}) " |
There was a problem hiding this comment.
Do we need to convert to to_py() and wrap with int? Can we just let it be as param_value?
| ): | ||
| self.unsupported( | ||
| f"{type_value.value} parameter ({int(param_value.to_py())}) " | ||
| f"exceeds {self.dialect.__class__.__name__}'s maximum capping to {bound}" |
There was a problem hiding this comment.
Not sure if this reads well, did you mean to write it as <type> parameter exceeds dialects maximum <bound>; Capping.?
| new_param = param.copy() | ||
| capped = exp.Literal.number(bound) | ||
| if isinstance(new_param, exp.DataTypeParam): | ||
| new_param.set("this", capped) | ||
| else: | ||
| new_param = capped | ||
| new_params[i] = new_param | ||
| changed = True |
There was a problem hiding this comment.
Do we need the copy here and the swap logic?
| assert expr1.meta == {} | ||
|
|
||
| def test_pipe_and_apply(self) -> None: | ||
|
|
| TYPE_DEFAULT_PARAMS: t.ClassVar[dict[exp.DType, tuple[int, ...]]] = {} | ||
| TYPE_PARAM_BOUNDS: t.ClassVar[dict[exp.DType, tuple[int | None, ...]]] = {} |
There was a problem hiding this comment.
I wonder whether these could be a single data structure to avoid separate dict lookups
the default BIGDECIMAL to DECIMAL(38, 5) mapping was being concatenated with explicit (76, 38) params, producing DECIMAL(38, 5)(76, 38) in ducked:
added a check in
_datatype_sqlto pass through the usersupplied params when present instead and falling back to the default otherwise