-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] support named arguments for table functions #36596
Conversation
continue; | ||
} | ||
if (!Type.isImplicitlyCastable(other.argTypes[i], getVarArgsType(), true)) { | ||
if (!Type.isImplicitlyCastable(other.argTypes[i], this.argTypes[i], true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please tell people why and what you are doing in this CL.
select * from TABLE(generate_series(start=>2, stop=>5)); | ||
-- result: | ||
E: (1064, "Getting analyzing error. Detail message: Unknown table function 'generate_series(start=>2,stop=>5)', the function doesn't support named arguments or has invalid arguments.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
step is an optional argument, why it is not supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the second should be end
, not stop
, invalid arguments.
@@ -0,0 +1,12 @@ | |||
-- name: test named arguments for table functions | |||
|
|||
select * from TABLE(generate_series(start=>2, end=>5)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add tests to cover normal cases.
I see all cases are fail cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
fe/fe-core/src/main/java/com/starrocks/sql/analyzer/ExpressionAnalyzer.java
Show resolved
Hide resolved
@@ -2158,6 +2158,7 @@ expression | |||
| NOT expression #logicalNot | |||
| left=expression operator=(AND|LOGICAL_AND) right=expression #logicalBinary | |||
| left=expression operator=(OR|LOGICAL_OR) right=expression #logicalBinary | |||
| identifier '=>' expression #namedArgument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add it in functioncall is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or new a special expression ArgumentExpression
to resolve all function arguments? adding here will contaminate all expressions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is param1 => param2 => value_expr
valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may use a new rule like expression ('=>' expression) ?
to decribe the item in table fucntion arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
introduce namedArgumentList to narrow scop needed.
param1 => param2 => value_expr is invalid.
boolean[] mask = new boolean[other.argTypes.length]; | ||
for (int j = startArgIndex; j < other.argTypes.length; ++j) { | ||
boolean found = false; | ||
for (int i = startArgIndex; i < this.argTypes.length; ++i) { | ||
if (!mask[i] && this.argNames[i].equals(other.argNames[j])) { | ||
if (!other.argTypes[j].matchesType(this.argTypes[i]) && | ||
!Type.isImplicitlyCastable(other.argTypes[j], this.argTypes[i], true)) { | ||
return false; | ||
} | ||
found = true; | ||
mask[i] = true; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe you need extract some method, like getArgumentByName
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleaned.
@SerializedName(value = "argNames") | ||
private String[] argNames; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, why don't support a special class to resolve arguments? may be we need support all function in future? separate to handle the arguments and name isn't a sustainable practice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and if we need support postiation arguments and name arguments at sametime, define a unified abstraction is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding named argumetns seems change a few codes, seems no need add new class.
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
|
[FE Incremental Coverage Report]❌ fail : 145 / 183 (79.23%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com> Signed-off-by: 张敢 <zhanggan@deepexi.com>
support named arguments for table functions, keep the same behavior with Trino:
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
doc