[jira] [Commented] (CALCITE-2188) JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic

2018-03-23 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-2188:
--

Any reason why SqlDialect.unparseSqlIntervalLiteral calls {code}
writer.keyword(interval.getIntervalQualifier().toSqlString(writer.getDialect()).getSql());
{code} rather than calling {{SqlDialect.unparseSqlIntervalLiteralQualifier}} 
directly?

> JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic
> ---
>
> Key: CALCITE-2188
> URL: https://issues.apache.org/jira/browse/CALCITE-2188
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Reporter: Rahul Raj
>Assignee: Julian Hyde
>Priority: Major
> Fix For: 1.17.0
>
>
> Calcite gives errors on Date interval addition/subtraction in the WHERE 
> clause. For example the query {code}select  * from \"sakila\".\"actor\" where 
>  \"last_update\" - INTERVAL '20' SECOND > TIMESTAMP '2005-10-17 
> 00:00:00'{code} gives
> {noformat}
> Caused by: java.lang.UnsupportedOperationException: class 
> org.apache.calcite.sql.SqlSyntax$6: SPECIAL
>      at org.apache.calcite.util.Util.needToImplement(Util.java:925) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:323) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNodeList.andOrList(SqlNodeList.java:142) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:347) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:197) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:240) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:158) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.drill.exec.store.jdbc.JdbcPrel.(JdbcPrel.java:65) 
> ~[drill-jdbc-storage-1.13.0-SNAPSHOT.jar:1.13.0-SNAPSHOT]{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2188) JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic

2018-03-17 Thread Rahul Raj (JIRA)

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

Rahul Raj commented on CALCITE-2188:


[~julianhyde] I have incorporated your review comments and rebased the change 
on to the same commit. Please have a look.

Again, CI passed on jdk8, failed on jdk9!

> JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic
> ---
>
> Key: CALCITE-2188
> URL: https://issues.apache.org/jira/browse/CALCITE-2188
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Reporter: Rahul Raj
>Assignee: Julian Hyde
>Priority: Major
> Fix For: 1.17.0
>
>
> Calcite gives errors on Date interval addition/subtraction in the WHERE 
> clause. For example the query {code}select  * from \"sakila\".\"actor\" where 
>  \"last_update\" - INTERVAL '20' SECOND > TIMESTAMP '2005-10-17 
> 00:00:00'{code} gives
> {noformat}
> Caused by: java.lang.UnsupportedOperationException: class 
> org.apache.calcite.sql.SqlSyntax$6: SPECIAL
>      at org.apache.calcite.util.Util.needToImplement(Util.java:925) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:323) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNodeList.andOrList(SqlNodeList.java:142) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:347) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:197) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:240) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:158) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.drill.exec.store.jdbc.JdbcPrel.(JdbcPrel.java:65) 
> ~[drill-jdbc-storage-1.13.0-SNAPSHOT.jar:1.13.0-SNAPSHOT]{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2188) JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic

2018-03-12 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-2188:
--

Reviewing 
[bc26af6|https://github.com/apache/calcite/pull/641/commits/bc26af6b0b84d698528f556dacd8f7a81a5f9d6f]:
* Formatting a bit off in some places (indent should be 4)
* There are javadoc comments in a place that should be a regular comment
* Now {{useDefaultStartPrecision}} and {{useDefaultFractionalSecondPrecision}} 
are public they need javadoc.
* Some of those IllegalArgumentException should be AssertionError. Internal 
error, not client error.
* The javadoc of SqlDatetimeAdditionOperator is wrong. It does NOT add two 
datetimes.  I can tell you copy-pasted from SqlDatetimeSubtractionOperator.

> JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic
> ---
>
> Key: CALCITE-2188
> URL: https://issues.apache.org/jira/browse/CALCITE-2188
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Reporter: Rahul Raj
>Assignee: Julian Hyde
>Priority: Major
> Fix For: 1.16.0
>
>
> Calcite gives errors on Date interval addition/subtraction in the WHERE 
> clause. For example the query {code}select  * from \"sakila\".\"actor\" where 
>  \"last_update\" - INTERVAL '20' SECOND > TIMESTAMP '2005-10-17 
> 00:00:00'{code} gives
> {noformat}
> Caused by: java.lang.UnsupportedOperationException: class 
> org.apache.calcite.sql.SqlSyntax$6: SPECIAL
>      at org.apache.calcite.util.Util.needToImplement(Util.java:925) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:323) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNodeList.andOrList(SqlNodeList.java:142) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:347) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:197) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:240) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:158) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.drill.exec.store.jdbc.JdbcPrel.(JdbcPrel.java:65) 
> ~[drill-jdbc-storage-1.13.0-SNAPSHOT.jar:1.13.0-SNAPSHOT]{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2188) JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic

2018-03-03 Thread Rahul Raj (JIRA)

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

Rahul Raj commented on CALCITE-2188:


Please find the PR [https://github.com/apache/calcite/pull/641]

All tests passes locally on my system.

CI passed on jdk8, failed on jdk9

> JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic
> ---
>
> Key: CALCITE-2188
> URL: https://issues.apache.org/jira/browse/CALCITE-2188
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Reporter: Rahul Raj
>Assignee: Julian Hyde
>Priority: Major
>
> Calcite gives errors on Date interval addition/subtraction in the WHERE 
> clause. For example the query {code}select  * from \"sakila\".\"actor\" where 
>  \"last_update\" - INTERVAL '20' SECOND > TIMESTAMP '2005-10-17 
> 00:00:00'{code} gives
> {noformat}
> Caused by: java.lang.UnsupportedOperationException: class 
> org.apache.calcite.sql.SqlSyntax$6: SPECIAL
>      at org.apache.calcite.util.Util.needToImplement(Util.java:925) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:323) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNodeList.andOrList(SqlNodeList.java:142) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:347) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:197) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:240) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:158) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.drill.exec.store.jdbc.JdbcPrel.(JdbcPrel.java:65) 
> ~[drill-jdbc-storage-1.13.0-SNAPSHOT.jar:1.13.0-SNAPSHOT]{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2188) JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic

2018-02-27 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-2188:
--

Sounds promising. I hope you're adding tests for the SQL generated in each 
dialect. Looking forward to the PR.

> JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic
> ---
>
> Key: CALCITE-2188
> URL: https://issues.apache.org/jira/browse/CALCITE-2188
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Reporter: Rahul Raj
>Assignee: Julian Hyde
>Priority: Major
>
> Calcite gives errors on Date interval addition/subtraction in the WHERE 
> clause. For example the query {code}select  * from \"sakila\".\"actor\" where 
>  \"last_update\" - INTERVAL '20' SECOND > TIMESTAMP '2005-10-17 
> 00:00:00'{code} gives
> {noformat}
> Caused by: java.lang.UnsupportedOperationException: class 
> org.apache.calcite.sql.SqlSyntax$6: SPECIAL
>      at org.apache.calcite.util.Util.needToImplement(Util.java:925) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:323) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNodeList.andOrList(SqlNodeList.java:142) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:347) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:197) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:240) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:158) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.drill.exec.store.jdbc.JdbcPrel.(JdbcPrel.java:65) 
> ~[drill-jdbc-storage-1.13.0-SNAPSHOT.jar:1.13.0-SNAPSHOT]{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2188) JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic

2018-02-27 Thread Rahul Raj (JIRA)

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

Rahul Raj commented on CALCITE-2188:


I have made the following fixes:
 # Interval Addition (column + INTERVAL '19800' SECOND(5)) was implemented
 # Fixed Interval subtraction(column - INTERVAL '19800' SECOND(5)) - was 
failing with an index out of bounds exception
 # Changed MySqlDialect to ignore the precision value unsupported in MySql
 # MS SQL Server does not support INTERVAL, mapped to DATEADD(SECOND, 19800, 
[hire_date]) in MSSqlDialect.
 # Have tested against Postgres, MySql, Oracle and Sql Server.

I need to test against DB2 and will submit the PR this weekend.

> JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic
> ---
>
> Key: CALCITE-2188
> URL: https://issues.apache.org/jira/browse/CALCITE-2188
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Reporter: Rahul Raj
>Assignee: Julian Hyde
>Priority: Major
>
> Calcite gives errors on Date interval addition/subtraction in the WHERE 
> clause. For example the query {code}select  * from \"sakila\".\"actor\" where 
>  \"last_update\" - INTERVAL '20' SECOND > TIMESTAMP '2005-10-17 
> 00:00:00'{code} gives
> {noformat}
> Caused by: java.lang.UnsupportedOperationException: class 
> org.apache.calcite.sql.SqlSyntax$6: SPECIAL
>      at org.apache.calcite.util.Util.needToImplement(Util.java:925) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:323) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNodeList.andOrList(SqlNodeList.java:142) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:347) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:197) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:240) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:158) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.drill.exec.store.jdbc.JdbcPrel.(JdbcPrel.java:65) 
> ~[drill-jdbc-storage-1.13.0-SNAPSHOT.jar:1.13.0-SNAPSHOT]{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2188) JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic

2018-02-22 Thread Rahul Raj (JIRA)

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

Rahul Raj commented on CALCITE-2188:


The INTERVAL syntax is different between databases. Any thoughts on how many 
databases to be supported?

> JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic
> ---
>
> Key: CALCITE-2188
> URL: https://issues.apache.org/jira/browse/CALCITE-2188
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Reporter: Rahul Raj
>Assignee: Julian Hyde
>Priority: Major
>
> Calcite gives errors on Date interval addition/subtraction in the WHERE 
> clause. For example the query {code}select  * from \"sakila\".\"actor\" where 
>  \"last_update\" - INTERVAL '20' SECOND > TIMESTAMP '2005-10-17 
> 00:00:00'{code} gives
> {noformat}
> Caused by: java.lang.UnsupportedOperationException: class 
> org.apache.calcite.sql.SqlSyntax$6: SPECIAL
>      at org.apache.calcite.util.Util.needToImplement(Util.java:925) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:323) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNodeList.andOrList(SqlNodeList.java:142) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:347) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:197) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:240) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:158) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.drill.exec.store.jdbc.JdbcPrel.(JdbcPrel.java:65) 
> ~[drill-jdbc-storage-1.13.0-SNAPSHOT.jar:1.13.0-SNAPSHOT]{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2188) JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic

2018-02-21 Thread Rahul Raj (JIRA)

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

Rahul Raj commented on CALCITE-2188:


I have it ready. I will test few more cases/DBs and will submit in a day.

> JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic
> ---
>
> Key: CALCITE-2188
> URL: https://issues.apache.org/jira/browse/CALCITE-2188
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Reporter: Rahul Raj
>Assignee: Julian Hyde
>Priority: Major
>
> Calcite gives errors on Date interval addition/subtraction in the WHERE 
> clause. For example the query {code}select  * from \"sakila\".\"actor\" where 
>  \"last_update\" - INTERVAL '20' SECOND > TIMESTAMP '2005-10-17 
> 00:00:00'{code} gives
> {noformat}
> Caused by: java.lang.UnsupportedOperationException: class 
> org.apache.calcite.sql.SqlSyntax$6: SPECIAL
>      at org.apache.calcite.util.Util.needToImplement(Util.java:925) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:323) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNodeList.andOrList(SqlNodeList.java:142) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:347) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:197) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:240) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:158) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.drill.exec.store.jdbc.JdbcPrel.(JdbcPrel.java:65) 
> ~[drill-jdbc-storage-1.13.0-SNAPSHOT.jar:1.13.0-SNAPSHOT]{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2188) JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic

2018-02-21 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-2188:
--

Do you have a PR?

> JDBC adapter generates invalid SQL for DATE/INTERVAL arithmetic
> ---
>
> Key: CALCITE-2188
> URL: https://issues.apache.org/jira/browse/CALCITE-2188
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Reporter: Rahul Raj
>Assignee: Julian Hyde
>Priority: Major
>
> Calcite gives errors on Date interval addition/subtraction in the WHERE 
> clause. For example the query {code}select  * from \"sakila\".\"actor\" where 
>  \"last_update\" - INTERVAL '20' SECOND > TIMESTAMP '2005-10-17 
> 00:00:00'{code} gives
> {noformat}
> Caused by: java.lang.UnsupportedOperationException: class 
> org.apache.calcite.sql.SqlSyntax$6: SPECIAL
>      at org.apache.calcite.util.Util.needToImplement(Util.java:925) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:323) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:332) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.dialect.MysqlSqlDialect.unparseCall(MysqlSqlDialect.java:154)
>  ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNodeList.andOrList(SqlNodeList.java:142) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:347) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at 
> org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:197) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:240) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:158) 
> ~[calcite-core-1.15.0-drill-r0.jar:1.15.0-drill-r0]
>      at org.apache.drill.exec.store.jdbc.JdbcPrel.(JdbcPrel.java:65) 
> ~[drill-jdbc-storage-1.13.0-SNAPSHOT.jar:1.13.0-SNAPSHOT]{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)