[ 
https://issues.apache.org/jira/browse/CALCITE-6566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17880691#comment-17880691
 ] 

Julian Hyde commented on CALCITE-6566:
--------------------------------------

Reviewing the PR:
 * I think you should generalize this to all zero-arg function calls that are 
not system functions (like SYSDATE)
 * That means you no longer need an unparsePi method, you can use unparseCall
 * In sql strings with ā€˜\n’, break the string after the line ending. 

> JDBC adapter should generate PI function with parentheses in most dialects
> --------------------------------------------------------------------------
>
>                 Key: CALCITE-6566
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6566
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: xiong duan
>            Priority: Major
>              Labels: pull-request-available
>
> Now In Calcite, support the PI function:
> {code:java}
> select PI;
> return 3.141592653589793
> {code}
> Jdbc will generate:
> {code:java}
> SELECT PI AS "PI" FROM (VALUES (0)) AS "t" ("ZERO");{code}
> However, they always need parentheses when I test in different data sources.
> Spark:
> {code:java}
> select PI();
> return 3.141592653589793
> select PI;
> Error in query: cannot resolve '`PI`' given input columns: []; line 1 pos 
> 7;{code}
> Hive:
> {code:java}
> select PI();
> return 3.141592653589793
> select PI;
> SemanticException [Error 10004]: Line 1:7 Invalid table alias or column 
> reference 'PI': (possible column names are: ) (state=42000,code=10004){code}
> Postgresql:
> {code:java}
> select PI();
> return 3.141592653589793
> select PI;
> ERROR: column "pi" does not exist{code}
> MySQL:
> {code:java}
> select PI();
> return 3.141593
> select PI;
> ERROR 1054 (42S22) at line 1: Unknown column 'PI' in 'field list'{code}
> SQLServer:
> {code:java}
> select PI();
> 3.1415926535897931
> select PI;{code}
> So I will generate PI() in Jdbc Dialect.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to