Commit c1ed4fa
authored
Fix Polars expr pushdown (#102)
See #98
We have our own Polars IO plugin to create lazy polars dataframes. We
try to push as many predicates down into DuckDB as we can, for which we
try to map Polars expressions (including datatypes) to SQL expressions.
To do this we depend on Polar's `Expr.meta.serialize`.
None of this is very stable. Polars IO source plugins are marked
`@unstable` and `Expr.meta.serialize` says "Serialization is not stable
across Polars versions".
In this case the problems seems to come from Polars requiring an
explicit scale to be set for decimals ([this
pr](pola-rs/polars#24542)). The serialized
format seems to have changed into:
```json
{
"expr": {
"Literal": {
"Scalar": {
"Decimal": [
1,
38, // This now includes the scale
0
]
}
}
},
"dtype": {
"Literal": {
"Decimal": [
38, // this was already there
0
]
}
},
"options": "Strict"
}
```
Interestingly, even if we explicitly set precision to e.g. 20, the
relevant part of the serialized expression looks as follows:
```json
{
"expr": {
"Literal": {
"Scalar": {
"Decimal": [
1,
38, // Still 38?
0
]
}
}
},
"dtype": {
"Literal": {
"Decimal": [
20, // This is correct
0
]
}
},
"options": "Strict"
}
```
This PR allows for both a 2 and 3 item list for decimals.2 files changed
+58
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
179 | | - | |
| 180 | + | |
180 | 181 | | |
181 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
| |||
260 | 264 | | |
261 | 265 | | |
262 | 266 | | |
263 | | - | |
| 267 | + | |
| 268 | + | |
264 | 269 | | |
265 | 270 | | |
266 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
178 | | - | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| |||
605 | 606 | | |
606 | 607 | | |
607 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
0 commit comments