Hi Mihai,
Thank you very much for letting me know the community principle.
There is another question, does toSqlString follow the sql standard, or just 
plain display use.
Do you think it is reasonable to fix it in toSqlString side, currently the key 
is that after toSqlString cause the parsing exception.


From: Mihai Budiu <[email protected]>
Date: Tuesday, April 15, 2025 at 12:15
To: [email protected] <[email protected]>
Subject: Re: [DISCUSS] (CALCITE-6944)Cannot parse parenthesized partition by in 
Table Function
External Email

There are a lot of open PRs, so it's easy for one to fall through the cracks.

I think you should answer a simple question: what is the correct grammar? You 
are making it look like you are tweaking the grammar to allow it to parse what 
the output of the compiler is. But that's the wrong question. The compiler 
should output what the correct output is.

"Correct" is defined as in "specified by the standard" or "supported by other 
databases".

I didn't review your PR because I don't know the answer to this last question.

Mihai

________________________________
From: Zhang, Juntao
Sent: Monday, April 14, 2025 9:03 PM
To: [email protected]
Subject: [DISCUSS] (CALCITE-6944)Cannot parse parenthesized partition by in 
Table Function

Hi team,
For  
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fissues.apache.org%2Fjira%2Fbrowse%2FCALCITE-6944&data=05%7C02%7Cjuntzhang%40ebay.com%7C9e3371ad1ffa4fc4fbd308dd7bd420a0%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C638802873230509688%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=qPfNTxJprnl2oaGQ2AyO12y14L3F3ElFYQF6FQtN5SU%3D&reserved=0<https://issues.apache.org/jira/browse/CALCITE-6944>,
  I’m happy to make the GitHub Pull Request 
#4295<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Fcalcite%2Fpull%2F4295&data=05%7C02%7Cjuntzhang%40ebay.com%7C9e3371ad1ffa4fc4fbd308dd7bd420a0%7C46326bff992841a0baca17c16c94ea99%7C0%7C0%7C638802873230537427%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=uFvCqvuDbCc%2FsnNW835ZxYHNp6pmFgQNz8shvHo7Q9w%3D&reserved=0<https://github.com/apache/calcite/pull/4295>>
 to fix it as well if we think its worth fixing. Can someone tell me how to 
move forward?

This the issue of an extra parenthesis in the table function.
Why there is an extra parenthesis?
Currently toSqlString this method will add parentheses, which means that the 
SQL after toSqlString cannot be parsed.

Test example:
    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);

Thanks
Juntao

Reply via email to