Skip to content

fix(e6): default single-argument LOG to natural-log base e - #285

Merged
tkaunlaky-e6 merged 1 commit into
mainfrom
fix/e6-single-arg-log-default-base
Jul 27, 2026
Merged

fix(e6): default single-argument LOG to natural-log base e#285
tkaunlaky-e6 merged 1 commit into
mainfrom
fix/e6-single-arg-log-default-base

Conversation

@tkaunlaky-e6

Copy link
Copy Markdown

What

DBR (and Spark/Hive/BigQuery) treat a single-argument LOG(x) as the natural logarithm (base e). e6 requires an explicit base, so a single-arg LOG currently transpiles to LOG(a), which fails at execution.

This supplies the default base e = 2.718281828459045 (fetched from DBR's e()) whenever a single-argument LOG is encountered:

SELECT log(a)     -->  SELECT LOG(2.718281828459045, a)

How

In the e6 generator:

  • exp.Log single-arg → LOG(2.718281828459045, x) (covers e6/presto/snowflake/postgres read paths, which produce a Log node).
  • exp.Ln where the source function name was logLOG(2.718281828459045, x). This is the DBR path: Databricks parses single-arg log(a) into a natural-log (Ln) node tagged with the original name in meta. A genuine LN(x) is left as LN(x).

Two-argument LOG(base, value) is unchanged.

Verified

input (read=databricks) output (e6)
log(a) LOG(2.718281828459045, a)
log(a, b) LOG(a, b)
ln(a) LN(a)
log10(a) LOG(10, a)

Tests

Added cases to test_math in tests/dialects/test_e6.py (DBR single-arg, two-arg, e6 identity). Full e6 + databricks suites pass, no regressions.

DBR treats a single-argument LOG(x) as the natural logarithm (base e),
but e6 requires an explicit base. Supply e = 2.718281828459045 so that
single-arg LOG becomes LOG(2.718281828459045, x). DBR parses single-arg
LOG(x) into an Ln node tagged with the original name, so handle that case
too while leaving a genuine LN(x) untouched. Two-argument LOG(base, value)
is unchanged.
@tkaunlaky-e6
tkaunlaky-e6 merged commit bba522a into main Jul 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants