Fix Presto LOG(b, x) argument order on round-trip [CLAUDE]#7905
Closed
chuenchen309 wants to merge 1 commit into
Closed
Fix Presto LOG(b, x) argument order on round-trip [CLAUDE]#7905chuenchen309 wants to merge 1 commit into
chuenchen309 wants to merge 1 commit into
Conversation
Presto's LOG(b, x) is log base b of x, but round-tripping through the Presto dialect swapped the two arguments, turning LOG(3, 9) into LOG(9, 3). The parser treated a None LOG_BASE_FIRST as falsy and swapped, while the generator only swaps when the flag is explicitly False; aligning the parser to `is False` fixes it and leaves base-first (True) and value-first (False) dialects unchanged. Co-authored-by AI: Claude (Claude Code). [CLAUDE]
geooo109
reviewed
Jul 20, 2026
Comment on lines
+719
to
+720
| self.validate_identity("SELECT LOG(x, y)") | ||
| self.validate_identity("SELECT LOG(3, 9)") |
Collaborator
There was a problem hiding this comment.
This is invalid in presto:
presto> SELECT LOG(2,8);
Query 20260720_104252_00010_i6tgb, FAILED, 0 nodes
Splits: 0 total, 0 done (0.00%)
[Latency: client-side: 16ms, server-side: 2ms] [0 rows, 0B] [0 rows/s, 0B/s]
Query 20260720_104252_00010_i6tgb failed: line 1:8: Function log not registered
SELECT LOG(2,8)
In trino (it's supported + the roundtrip is correct):
INPUT:
SELECT LOG(b, x)
AST:
Select(
expressions=[
Log(
this=Column(
this=Identifier(this=b, quoted=False)),
expression=Column(
this=Identifier(this=x, quoted=False)))])
SELECT LOG(b, x)
On the engine (trino):
trino> SELECT LOG(2,8);
_col0
-------
3.0
(1 row)
Query 20260720_104653_00001_q59b3, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0.13 [0 rows, 0B] [0 rows/s, 0B/s]
Collaborator
|
Assuming garbage in -> garbage out, this PR changes nothing:
Therefore, every input whose behavior the PR changes is garbage. |
This was referenced Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Presto's
LOG(b, x)is the logarithm ofxto baseb, but round-tripping it through the Presto dialect silently swaps the two arguments:LOG(3, 9)(log base 3 of 9, = 2) comes back out asLOG(9, 3)(= 0.5). The SQL still looks valid, so the wrong value is easy to miss.The cause is an inconsistency around the tri-state
LOG_BASE_FIRSTflag. Presto leaves itNone; the parser treatedNoneas falsy and swapped the arguments, while the generator only swaps when the flag is explicitlyFalse. Changing the parser's check tois Falsematches the generator, soNonedialects no longer swap. Base-first (True) and value-first (False) dialects are unaffected, andLOG2/LOG10still transpile as before.Verified against the full unit suite (1243 tests pass) and added a Presto round-trip test that fails without the change.
Disclosure: this change was found, fixed, tested and described by an AI agent (Claude Code) running on this account. The account holder reviews every change and is accountable for it.