fix: try to lower plain reserved functions to columns as well#16669
Merged
alamb merged 1 commit intoapache:mainfrom Jul 8, 2025
Merged
fix: try to lower plain reserved functions to columns as well#16669alamb merged 1 commit intoapache:mainfrom
alamb merged 1 commit intoapache:mainfrom
Conversation
When a reserved function like `user` is called without parenthesis, it may as well be a column. This works in PostgreSQL for example: ```text psql (17.5 (Debian 17.5-1.pgdg120+1)) Type "help" for help. postgres=# create table t(a int, "user" text); CREATE TABLE postgres=# insert into t values (1, 'foo'); INSERT 0 1 postgres=# select t.user from t; user ------ foo (1 row) postgres=# select user from t; user ---------- postgres (1 row) ``` However sqlparser tries to detect these functions, see apache/datafusion-sqlparser-rs#1909 We now first try to use the respective function and then also consider columns. Fixes apache#14141.
7adc63a to
95805f0
Compare
alamb
approved these changes
Jul 7, 2025
Contributor
alamb
left a comment
There was a problem hiding this comment.
Thank you @crepererum -- looks good to me
cc @jonahgao in case you also have time to review
| /// WITHIN GROUP clause, if any | ||
| within_group: Vec<OrderByExpr>, | ||
| /// Was the function called without parenthesis, i.e. could this also be a column reference? | ||
| function_without_paranthesis: bool, |
Contributor
There was a problem hiding this comment.
I think there is a typo here:
Suggested change
| function_without_paranthesis: bool, | |
| function_without_parenthesis: bool, |
Contributor
|
Thank you for the review @jonahgao ❤️ |
epsio-kogro
pushed a commit
to Epsio-Labs/arrow-datafusion
that referenced
this pull request
Jul 13, 2025
…#16669) When a reserved function like `user` is called without parenthesis, it may as well be a column. This works in PostgreSQL for example: ```text psql (17.5 (Debian 17.5-1.pgdg120+1)) Type "help" for help. postgres=# create table t(a int, "user" text); CREATE TABLE postgres=# insert into t values (1, 'foo'); INSERT 0 1 postgres=# select t.user from t; user ------ foo (1 row) postgres=# select user from t; user ---------- postgres (1 row) ``` However sqlparser tries to detect these functions, see apache/datafusion-sqlparser-rs#1909 We now first try to use the respective function and then also consider columns. Fixes apache#14141.
epsio-kogro
pushed a commit
to Epsio-Labs/arrow-datafusion
that referenced
this pull request
Jul 13, 2025
…#16669) When a reserved function like `user` is called without parenthesis, it may as well be a column. This works in PostgreSQL for example: ```text psql (17.5 (Debian 17.5-1.pgdg120+1)) Type "help" for help. postgres=# create table t(a int, "user" text); CREATE TABLE postgres=# insert into t values (1, 'foo'); INSERT 0 1 postgres=# select t.user from t; user ------ foo (1 row) postgres=# select user from t; user ---------- postgres (1 row) ``` However sqlparser tries to detect these functions, see apache/datafusion-sqlparser-rs#1909 We now first try to use the respective function and then also consider columns. Fixes apache#14141.
epsio-kogro
pushed a commit
to Epsio-Labs/arrow-datafusion
that referenced
this pull request
Jul 13, 2025
…#16669) When a reserved function like `user` is called without parenthesis, it may as well be a column. This works in PostgreSQL for example: ```text psql (17.5 (Debian 17.5-1.pgdg120+1)) Type "help" for help. postgres=# create table t(a int, "user" text); CREATE TABLE postgres=# insert into t values (1, 'foo'); INSERT 0 1 postgres=# select t.user from t; user ------ foo (1 row) postgres=# select user from t; user ---------- postgres (1 row) ``` However sqlparser tries to detect these functions, see apache/datafusion-sqlparser-rs#1909 We now first try to use the respective function and then also consider columns. Fixes apache#14141.
epsio-kogro
pushed a commit
to Epsio-Labs/arrow-datafusion
that referenced
this pull request
Jul 16, 2025
…#16669) When a reserved function like `user` is called without parenthesis, it may as well be a column. This works in PostgreSQL for example: ```text psql (17.5 (Debian 17.5-1.pgdg120+1)) Type "help" for help. postgres=# create table t(a int, "user" text); CREATE TABLE postgres=# insert into t values (1, 'foo'); INSERT 0 1 postgres=# select t.user from t; user ------ foo (1 row) postgres=# select user from t; user ---------- postgres (1 row) ``` However sqlparser tries to detect these functions, see apache/datafusion-sqlparser-rs#1909 We now first try to use the respective function and then also consider columns. Fixes apache#14141.
ThinkRedstone
pushed a commit
to Epsio-Labs/arrow-datafusion
that referenced
this pull request
Sep 29, 2025
…#16669) When a reserved function like `user` is called without parenthesis, it may as well be a column. This works in PostgreSQL for example: ```text psql (17.5 (Debian 17.5-1.pgdg120+1)) Type "help" for help. postgres=# create table t(a int, "user" text); CREATE TABLE postgres=# insert into t values (1, 'foo'); INSERT 0 1 postgres=# select t.user from t; user ------ foo (1 row) postgres=# select user from t; user ---------- postgres (1 row) ``` However sqlparser tries to detect these functions, see apache/datafusion-sqlparser-rs#1909 We now first try to use the respective function and then also consider columns. Fixes apache#14141.
maorsaleh
pushed a commit
to Epsio-Labs/arrow-datafusion
that referenced
this pull request
Nov 30, 2025
…#16669) When a reserved function like `user` is called without parenthesis, it may as well be a column. This works in PostgreSQL for example: ```text psql (17.5 (Debian 17.5-1.pgdg120+1)) Type "help" for help. postgres=# create table t(a int, "user" text); CREATE TABLE postgres=# insert into t values (1, 'foo'); INSERT 0 1 postgres=# select t.user from t; user ------ foo (1 row) postgres=# select user from t; user ---------- postgres (1 row) ``` However sqlparser tries to detect these functions, see apache/datafusion-sqlparser-rs#1909 We now first try to use the respective function and then also consider columns. Fixes apache#14141.
maorsaleh
pushed a commit
to Epsio-Labs/arrow-datafusion
that referenced
this pull request
Dec 3, 2025
…#16669) When a reserved function like `user` is called without parenthesis, it may as well be a column. This works in PostgreSQL for example: ```text psql (17.5 (Debian 17.5-1.pgdg120+1)) Type "help" for help. postgres=# create table t(a int, "user" text); CREATE TABLE postgres=# insert into t values (1, 'foo'); INSERT 0 1 postgres=# select t.user from t; user ------ foo (1 row) postgres=# select user from t; user ---------- postgres (1 row) ``` However sqlparser tries to detect these functions, see apache/datafusion-sqlparser-rs#1909 We now first try to use the respective function and then also consider columns. Fixes apache#14141.
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.
Which issue does this PR close?
Fixes #14141.
Rationale for this change
When a reserved function like
useris called without parenthesis, it may as well be a column. This works in PostgreSQL for example:However sqlparser tries to detect these functions, see apache/datafusion-sqlparser-rs#1909
What changes are included in this PR?
We now first try to use the respective function and then also consider columns.
Are these changes tested?
More sqllogictests
Are there any user-facing changes?
More queries work as expected (IMHO).