Skip to content

fix: compile log without base as natural log#12000

Open
BharatDeva wants to merge 1 commit into
ibis-project:mainfrom
BharatDeva:fix/log-without-base-natural-log
Open

fix: compile log without base as natural log#12000
BharatDeva wants to merge 1 commit into
ibis-project:mainfrom
BharatDeva:fix/log-without-base-natural-log

Conversation

@BharatDeva
Copy link
Copy Markdown

Description of changes

Fixes .log() without an explicit base so it is treated as natural log instead of passing a missing base through as NULL.

The issue is visible in Snowflake SQL generation, where table.value.log() compiled to LOG(NULL, value), and in Polars execution, where the result came back as NaN. This change checks the original operation (op.base) when deciding whether a base was provided, instead of relying on the already-translated backend argument.

This also updates the Polars compiler to call arg.log() for the natural-log case and adds focused regression coverage for Snowflake SQL generation and Polars execution.

Issues closed

Testing

.\.venv\Scripts\pytest ibis\backends\snowflake\tests\test_compiler.py::test_log_without_base_uses_natural_log
# 1 passed

.\.venv\Scripts\pytest ibis\backends\polars\tests\test_client.py::test_log_without_base_uses_natural_log
# 1 passed

.\.venv\Scripts\ruff format --check ibis\backends\polars\compiler.py ibis\backends\polars\tests\test_client.py ibis\backends\sql\compilers\bigquery\__init__.py ibis\backends\sql\compilers\impala.py ibis\backends\sql\compilers\mssql.py ibis\backends\sql\compilers\oracle.py ibis\backends\sql\compilers\postgres.py ibis\backends\sql\compilers\snowflake.py ibis\backends\sql\compilers\sqlite.py ibis\backends\sql\compilers\trino.py ibis\backends\tests\test_numeric.py ibis\backends\snowflake\tests\test_compiler.py
# 12 files already formatted

.\.venv\Scripts\ruff check ibis\backends\polars\compiler.py ibis\backends\polars\tests\test_client.py ibis\backends\sql\compilers\bigquery\__init__.py ibis\backends\sql\compilers\impala.py ibis\backends\sql\compilers\mssql.py ibis\backends\sql\compilers\oracle.py ibis\backends\sql\compilers\postgres.py ibis\backends\sql\compilers\snowflake.py ibis\backends\sql\compilers\sqlite.py ibis\backends\sql\compilers\trino.py ibis\backends\tests\test_numeric.py ibis\backends\snowflake\tests\test_compiler.py
# All checks passed

git diff --check
# clean

@github-actions github-actions Bot added tests Issues or PRs related to tests bigquery The BigQuery backend sql Backends that generate SQL polars The polars backend snowflake The Snowflake backend labels May 9, 2026
Comment thread ibis/backends/snowflake/tests/test_compiler.py Outdated
Comment thread ibis/backends/polars/tests/test_client.py Outdated
@NickCrews
Copy link
Copy Markdown
Contributor

Thanks @BharatDeva this looks pretty good! Just two comments. Once you reply, and CI passes, I will merge.

@BharatDeva BharatDeva force-pushed the fix/log-without-base-natural-log branch from fdf43a8 to 52bcfdb Compare May 10, 2026 01:16
@NickCrews NickCrews enabled auto-merge (rebase) May 10, 2026 20:04
@NickCrews
Copy link
Copy Markdown
Contributor

NickCrews commented May 10, 2026

Thanks! Looks like this just needs a tiny adjustment to get risingwave to pass and then should be good! It looks to me like we should compile this to LN(arg)?

@NickCrews NickCrews disabled auto-merge May 10, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bigquery The BigQuery backend polars The polars backend snowflake The Snowflake backend sql Backends that generate SQL tests Issues or PRs related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Log function with no base returns null

2 participants