[
https://issues.apache.org/jira/browse/CALCITE-6944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17943186#comment-17943186
]
juntaozhang edited comment on CALCITE-6944 at 4/10/25 1:48 PM:
---------------------------------------------------------------
hi [~julianhyde], thanks for your reply.
https://issues.apache.org/jira/browse/CALCITE-4865 in this Jira allow table
functions to be polymorphic by [~jingzhang],
if these two cases are in the scope, there is one slight change about
*_AddArg0_* in *_Parser.jj_* (The red highlight indicates the differences from
the previous case.)
* select * from table(topn(data=>{color:#ff0000}({color}table orders partition
by (productid){color:#ff0000}){color}, col=>3))
*
select * from table(topn({color:#ff0000}({color}table orders partition by
(productid){color:#ff0000}){color}, 3))
here is change in {*}_AddArg0_{*}, I only add parentheses check:
!image-2025-04-10-21-47-46-829.png|width=618,height=335!
was (Author: juntaozhang):
hi [~julianhyde], thanks for your reply.
https://issues.apache.org/jira/browse/CALCITE-4865 in this Jira allow table
functions to be polymorphic by [~jingzhang],
if these two cases are in the scope, there is one slight change about
*_AddArg0_* in *_Parser.jj_* (The red highlight indicates the differences from
the previous case.)
* select * from table(topn(data=>{color:#FF0000}({color}table orders partition
by (productid){color:#FF0000}){color}, col=>3))
*
select * from table(topn({color:#FF0000}({color}table orders partition by
(productid){color:#FF0000}){color}, 3))
here is change in {*}_AddArg0_{*}, I only add parentheses check:
*_!image-2025-04-10-20-02-24-377.png|width=789,height=179!_*
> After calling toSqlString, the table function with partition by argument in
> SqlNode cannot be parsed
> ----------------------------------------------------------------------------------------------------
>
> Key: CALCITE-6944
> URL: https://issues.apache.org/jira/browse/CALCITE-6944
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.34.0
> Reporter: juntaozhang
> Priority: Major
> Labels: pull-request-available
> Attachments: image-2025-04-10-20-02-24-377.png,
> image-2025-04-10-21-47-46-829.png
>
>
> Test example:
> {code:java}
> String sqlExpected = "f(a => TABLE t PARTITION BY f1 ORDER BY f2, b =>
> 1)";
> String sqlActual = parseExpression(sqlExpected)
> .toSqlString(new AnsiSqlDialect(SqlDialect.EMPTY_CONTEXT)).getSql();
> parseExpression(sqlActual);
> {code}
> Exception details:
> {code:java}
> Caused by: org.apache.calcite.sql.parser.impl.ParseException: Encountered
> "PARTITION" at line 1, column 17.
> Was expecting one of:
> "EXCEPT" ...
> "FETCH" ...
> "INTERSECT" ...
> "LIMIT" ...
> "OFFSET" ...
> "ORDER" ...
> "MINUS" ...
> "UNION" ...
> ")" ...
> "," ...
> "." ...
>
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.generateParseException(SqlParserImpl.java:44126)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.jj_consume_token(SqlParserImpl.java:43937)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.ParenthesizedQueryOrCommaList(SqlParserImpl.java:899)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression3(SqlParserImpl.java:18702)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.AddExpression2b(SqlParserImpl.java:17806)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression2(SqlParserImpl.java:17848)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression(SqlParserImpl.java:17779)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.LeafQueryOrExpr(SqlParserImpl.java:17756)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.QueryOrExpr(SqlParserImpl.java:17108)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.OrderedQueryOrExpr(SqlParserImpl.java:585)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.PartitionedQueryOrQueryOrExpr(SqlParserImpl.java:6912)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.AddArg0(SqlParserImpl.java:2522)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.FunctionParameterList(SqlParserImpl.java:1962)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.NamedCall(SqlParserImpl.java:32128)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.NamedFunctionCall(SqlParserImpl.java:31690)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.AtomicRowExpression(SqlParserImpl.java:19461)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression3(SqlParserImpl.java:18666)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.AddExpression2b(SqlParserImpl.java:17806)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression2(SqlParserImpl.java:17848)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression(SqlParserImpl.java:17779)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.SqlExpressionEof(SqlParserImpl.java:17070)
> at
> org.apache.calcite.sql.parser.impl.SqlParserImpl.parseSqlExpressionEof(SqlParserImpl.java:204)
> at
> org.apache.calcite.sql.parser.SqlParser.parseExpression(SqlParser.java:139)
> ... 62 more
> {code}
> After to *_toSqlString_* table argument cannot be recognized when parentheses
> are added:
> F(A => {color:#FF0000}({color}TABLE T PARTITION BY F1 ORDER BY
> F2{color:#FF0000}){color}, B => 1)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)