ibis icon indicating copy to clipboard operation
ibis copied to clipboard

fix: include casts for numeric Literals except in comparisons

Open NickCrews opened this issue 9 months ago • 3 comments

Fixes https://github.com/ibis-project/ibis/issues/10890

I only ran this for duckdb locally, I'm curious to see how this does on all the other backends.

This is a bit of a one-off approach to special-case for the predicate pushdown problem described in project/ibis/issues/9662. eg we only make the special case of ops.UntypedNumericLiteral for numbers, but are there other instances where we also want to avoid a cast, so this should be a more general ops.UntypedLiteral?

  • Need to verify that the solution keeps the predicate pushdown described in https://github.com/ibis-project/ibis/issues/9662
  • The other backends tests for test_numeric_literal need to get updated, because now ibis.dtype_from_backend_string(ibis.literal(12.34, <type>).typeof()) == <type> is always true (yay!)

For myself, a few of the common tests to run

  • pytest -k numeric_literal -vv ibis/backends/tests/test_numeric.py
  • pytest --snapshot-update -vv ibis/backends/tests/sql/test_compiler.py
  • pytest --snapshot-update -vv ibis/backends/tests/sql/test_sql.py
  • pytest duckdb ibis/backends/duckdb/tests/test_geospatial.py

NickCrews avatar Mar 03 '25 19:03 NickCrews

Seems like this needs some TLC.

cpcloud avatar Jun 10 '25 12:06 cpcloud

Im going to wait on working on this until more of my easier PRs get merged

NickCrews avatar Jun 10 '25 16:06 NickCrews

Marking as draft to make review triage a bit easier!

cpcloud avatar Jun 15 '25 10:06 cpcloud