[jira] [Updated] (CALCITE-3171) SemiJoin on conditions push down throws IndexOutOfBoundsException
[ https://issues.apache.org/jira/browse/CALCITE-3171?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] ASF GitHub Bot updated CALCITE-3171: Labels: pull-request-available (was: ) > SemiJoin on conditions push down throws IndexOutOfBoundsException > - > > Key: CALCITE-3171 > URL: https://issues.apache.org/jira/browse/CALCITE-3171 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.19.0 >Reporter: godfrey he >Assignee: Danny Chan >Priority: Major > Labels: pull-request-available > > the following code in RelOptUtil#pushDownJoinConditions only does not > consider SEMI/ANTI join > {code:java} > if (!extraLeftExprs.isEmpty() || !extraRightExprs.isEmpty()) { > Mappings.TargetMapping mapping = > Mappings.createShiftMapping( > leftCount + extraLeftExprs.size() > + rightCount + extraRightExprs.size(), > 0, 0, leftCount, > leftCount, leftCount + extraLeftExprs.size(), rightCount); > relBuilder.project(relBuilder.fields(mapping.inverse())); > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (CALCITE-3170) ANTI join on conditions push down generates wrong plan
[ https://issues.apache.org/jira/browse/CALCITE-3170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] ASF GitHub Bot updated CALCITE-3170: Labels: pull-request-available (was: ) > ANTI join on conditions push down generates wrong plan > -- > > Key: CALCITE-3170 > URL: https://issues.apache.org/jira/browse/CALCITE-3170 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.19.0 >Reporter: godfrey he >Assignee: Danny Chan >Priority: Major > Labels: pull-request-available > > create table A (a int, b int); > create table B (c int, d int); > insert into A values (1, 1); > insert into A values (2, 2); > sql: > {code:sql} > select * from A where A.a not in (select B.c from B where A.b > 1); > {code} > the equivalent logical tree: > {code} > LogicalProject(a=[$0], b=[$1]) > +- LogicalProject(a=[$0], b=[$1]) >+- LogicalJoin(condition=[AND(OR(=($0, $3), IS NULL($0), IS NULL($3)), > $2)], joinType=[anti]) > :- LogicalProject(a=[$0], b=[$1], $f2=[>($1, 1)]) > : +- LogicalTableScan(table=[[A]]) > +- LogicalProject(c=[$0]) > +- LogicalFilter(condition=[true]) > +- LogicalTableScan(table=[[B]]) > {code} > the correct result is: (1, 1), (2, 2) > while if the predicate ($2 in join condition) is pushed into left side, the > result is (2, 2) which is incorrect. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (CALCITE-3171) SemiJoin on conditions push down throws IndexOutOfBoundsException
[ https://issues.apache.org/jira/browse/CALCITE-3171?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Danny Chan updated CALCITE-3171: Summary: SemiJoin on conditions push down throws IndexOutOfBoundsException (was: RelOptUtil#pushDownJoinConditions should handle SEMI/ANTI join specially about project shift mapping) > SemiJoin on conditions push down throws IndexOutOfBoundsException > - > > Key: CALCITE-3171 > URL: https://issues.apache.org/jira/browse/CALCITE-3171 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.19.0 >Reporter: godfrey he >Priority: Major > > the following code in RelOptUtil#pushDownJoinConditions only does not > consider SEMI/ANTI join > {code:java} > if (!extraLeftExprs.isEmpty() || !extraRightExprs.isEmpty()) { > Mappings.TargetMapping mapping = > Mappings.createShiftMapping( > leftCount + extraLeftExprs.size() > + rightCount + extraRightExprs.size(), > 0, 0, leftCount, > leftCount, leftCount + extraLeftExprs.size(), rightCount); > relBuilder.project(relBuilder.fields(mapping.inverse())); > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Assigned] (CALCITE-3171) SemiJoin on conditions push down throws IndexOutOfBoundsException
[ https://issues.apache.org/jira/browse/CALCITE-3171?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Danny Chan reassigned CALCITE-3171: --- Assignee: Danny Chan > SemiJoin on conditions push down throws IndexOutOfBoundsException > - > > Key: CALCITE-3171 > URL: https://issues.apache.org/jira/browse/CALCITE-3171 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.19.0 >Reporter: godfrey he >Assignee: Danny Chan >Priority: Major > > the following code in RelOptUtil#pushDownJoinConditions only does not > consider SEMI/ANTI join > {code:java} > if (!extraLeftExprs.isEmpty() || !extraRightExprs.isEmpty()) { > Mappings.TargetMapping mapping = > Mappings.createShiftMapping( > leftCount + extraLeftExprs.size() > + rightCount + extraRightExprs.size(), > 0, 0, leftCount, > leftCount, leftCount + extraLeftExprs.size(), rightCount); > relBuilder.project(relBuilder.fields(mapping.inverse())); > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (CALCITE-3170) ANTI join on conditions push down generates wrong plan
[ https://issues.apache.org/jira/browse/CALCITE-3170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Danny Chan updated CALCITE-3170: Summary: ANTI join on conditions push down generates wrong plan (was: join condition of ANTI join can not be pushed down) > ANTI join on conditions push down generates wrong plan > -- > > Key: CALCITE-3170 > URL: https://issues.apache.org/jira/browse/CALCITE-3170 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.19.0 >Reporter: godfrey he >Assignee: Danny Chan >Priority: Major > > create table A (a int, b int); > create table B (c int, d int); > insert into A values (1, 1); > insert into A values (2, 2); > sql: > {code:sql} > select * from A where A.a not in (select B.c from B where A.b > 1); > {code} > the equivalent logical tree: > {code} > LogicalProject(a=[$0], b=[$1]) > +- LogicalProject(a=[$0], b=[$1]) >+- LogicalJoin(condition=[AND(OR(=($0, $3), IS NULL($0), IS NULL($3)), > $2)], joinType=[anti]) > :- LogicalProject(a=[$0], b=[$1], $f2=[>($1, 1)]) > : +- LogicalTableScan(table=[[A]]) > +- LogicalProject(c=[$0]) > +- LogicalFilter(condition=[true]) > +- LogicalTableScan(table=[[B]]) > {code} > the correct result is: (1, 1), (2, 2) > while if the predicate ($2 in join condition) is pushed into left side, the > result is (2, 2) which is incorrect. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2843) Babel parser should parse PostgreSQL-style '::' cast operator
[ https://issues.apache.org/jira/browse/CALCITE-2843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16879760#comment-16879760 ] Muhammad Gelbana commented on CALCITE-2843: --- [~danny0405], I have a couple of questions regarding your comemnts on the PR. I've already asked those questions on the PR page but since you marked the PR as "discussiong-in-jira", we can discuss those questions here. (I personally prefer github in this case because the discussion can easily be associated with a selected piece of code) # [Here|https://github.com/apache/calcite/pull/1066#discussion_r300819535] You asked me to inherit {{SqlSpecialOperator}} instead of {{SqlBinaryOperator}}, why is that ? I'm confused because the operator is binary with no special syntax. # [Here|https://github.com/apache/calcite/pull/1066#discussion_r300819432] and [here|https://github.com/apache/calcite/pull/1066#discussion_r300819435], you asked me to add enough tests. I added tests for parsing {{INTEGER}}, {{VARCHAR}}, {{BOOLEAN}}, {{DOUBLE}}, {{BIGINT}}, if that's not enough, would you kindly suggest a way to go through all the possible types with valid castable data ? Has this been done somewhere in the current test framework ? # Regarding using the {{SqlStdOperatorTable.CAST}} instead of {{SqlStdOperatorTable.PG_CAST}}, I remember facing difficulties producing a function instead of a binary expression at that point in the parser but I'll try that again. Thanks a lot for your time so far. Hopefully we can get done with this soon inshallah. > Babel parser should parse PostgreSQL-style '::' cast operator > - > > Key: CALCITE-2843 > URL: https://issues.apache.org/jira/browse/CALCITE-2843 > Project: Calcite > Issue Type: Bug > Components: babel >Affects Versions: 1.18.0 >Reporter: Muhammad Gelbana >Assignee: Muhammad Gelbana >Priority: Major > Labels: postgresql, pull-request-available > Time Spent: 4h > Remaining Estimate: 0h > > *Code to reproduce the problem* > {code:java} > public static void main(String[] args) throws Exception { > Config parserConfig = > configBuilder().setConformance(SqlConformanceEnum.BABEL).setParserFactory(SqlBabelParserImpl.FACTORY).build(); > FrameworkConfig frameworkConfig = > Frameworks.newConfigBuilder().parserConfig(parserConfig).build(); > Planner planner = Frameworks.getPlanner(frameworkConfig); > String pg = "SELECT 'array_in'::regproc, typtype FROM pg_catalog.pg_type"; > planner.parse(pg); > }{code} > > *Thrown exception* > {noformat} > Exception in thread "main" org.apache.calcite.sql.parser.SqlParseException: > Encountered ":" at line 1, column 18. > Was expecting one of: > > "ORDER" ... > "LIMIT" ... > "OFFSET" ... > "FETCH" ... > "FROM" ... > "," ... > ... > ... > ... > ... > ... > ... > "." ... > "IN" ... > "<" ... > "<=" ... > ">" ... > ">=" ... > "=" ... > "<>" ... > "!=" ... > "+" ... > "-" ... > "*" ... > "/" ... > "%" ... > "||" ... > "[" ... > "UNION" ... > "INTERSECT" ... > "EXCEPT" ... > "MINUS" ... > > at > org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.convertException(SqlBabelParserImpl.java:354) > at > org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.normalizeException(SqlBabelParserImpl.java:142) > at > org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:156) > at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:181) > at org.apache.calcite.prepare.PlannerImpl.parse(PlannerImpl.java:174) > at org.apache.calcite.tools.Planner.parse(Planner.java:50) > at com.lab.calcite.App2.main(App2.java:23) > Caused by: org.apache.calcite.sql.parser.babel.ParseException: Encountered > ":" at line 1, column 18. > Was expecting one of: > > "ORDER" ... > "LIMIT" ... > "OFFSET" ... > "FETCH" ... > "FROM" ... > "," ... > ... > ... > ... > ... > ... > ... > "." ... > "IN" ... > "<" ... > "<=" ... > ">" ... > ">=" ... > "=" ... > "<>" ... > "!=" ... > "+" ... > "-" ... > "*" ... > "/" ... > "%" ... > "||" ... > "[" ... > "UNION" ... > "INTERSECT" ... > "EXCEPT" ... > "MINUS" ... > > at > org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.generateParseException(SqlBabelParserImpl.java:31191) > at > org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.jj_consume_token(SqlBabelParserImpl.java:31008) > at > org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.SqlStmtEof(SqlBabelParserImpl.java:877) >
[jira] [Updated] (CALCITE-3176) File adapter for parsing JSON files
[ https://issues.apache.org/jira/browse/CALCITE-3176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] ASF GitHub Bot updated CALCITE-3176: Labels: pull-request-available (was: ) > File adapter for parsing JSON files > --- > > Key: CALCITE-3176 > URL: https://issues.apache.org/jira/browse/CALCITE-3176 > Project: Calcite > Issue Type: New Feature >Reporter: Forward Xu >Assignee: Forward Xu >Priority: Major > Labels: pull-request-available > > File adapter for parsing JSON files -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Assigned] (CALCITE-3170) join condition of ANTI join can not be pushed down
[ https://issues.apache.org/jira/browse/CALCITE-3170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Danny Chan reassigned CALCITE-3170: --- Assignee: Danny Chan > join condition of ANTI join can not be pushed down > -- > > Key: CALCITE-3170 > URL: https://issues.apache.org/jira/browse/CALCITE-3170 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.19.0 >Reporter: godfrey he >Assignee: Danny Chan >Priority: Major > > create table A (a int, b int); > create table B (c int, d int); > insert into A values (1, 1); > insert into A values (2, 2); > sql: > {code:sql} > select * from A where A.a not in (select B.c from B where A.b > 1); > {code} > the equivalent logical tree: > {code} > LogicalProject(a=[$0], b=[$1]) > +- LogicalProject(a=[$0], b=[$1]) >+- LogicalJoin(condition=[AND(OR(=($0, $3), IS NULL($0), IS NULL($3)), > $2)], joinType=[anti]) > :- LogicalProject(a=[$0], b=[$1], $f2=[>($1, 1)]) > : +- LogicalTableScan(table=[[A]]) > +- LogicalProject(c=[$0]) > +- LogicalFilter(condition=[true]) > +- LogicalTableScan(table=[[B]]) > {code} > the correct result is: (1, 1), (2, 2) > while if the predicate ($2 in join condition) is pushed into left side, the > result is (2, 2) which is incorrect. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (CALCITE-3175) Serialize to json of trim function cause exception
[ https://issues.apache.org/jira/browse/CALCITE-3175?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] ASF GitHub Bot updated CALCITE-3175: Labels: pull-request-available (was: ) > Serialize to json of trim function cause exception > -- > > Key: CALCITE-3175 > URL: https://issues.apache.org/jira/browse/CALCITE-3175 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Wang Yanlin >Priority: Major > Labels: pull-request-available > > Serialize the RexCall of *trim* function cause *java.lang.AssertionError* > exception. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Assigned] (CALCITE-3176) File adapter for parsing JSON files
[ https://issues.apache.org/jira/browse/CALCITE-3176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Forward Xu reassigned CALCITE-3176: --- Assignee: Forward Xu > File adapter for parsing JSON files > --- > > Key: CALCITE-3176 > URL: https://issues.apache.org/jira/browse/CALCITE-3176 > Project: Calcite > Issue Type: New Feature >Reporter: Forward Xu >Assignee: Forward Xu >Priority: Major > > File adapter for parsing JSON files -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-3176) File adapter for parsing JSON files
Forward Xu created CALCITE-3176: --- Summary: File adapter for parsing JSON files Key: CALCITE-3176 URL: https://issues.apache.org/jira/browse/CALCITE-3176 Project: Calcite Issue Type: New Feature Reporter: Forward Xu File adapter for parsing JSON files -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-3175) Serialize to json of trim function cause exception
Wang Yanlin created CALCITE-3175: Summary: Serialize to json of trim function cause exception Key: CALCITE-3175 URL: https://issues.apache.org/jira/browse/CALCITE-3175 Project: Calcite Issue Type: Bug Components: core Reporter: Wang Yanlin Serialize the RexCall of *trim* function cause *java.lang.AssertionError* exception. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-3100) cast(? as DATE) won't work with PreparedStatement
[ https://issues.apache.org/jira/browse/CALCITE-3100?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16879659#comment-16879659 ] Danny Chan commented on CALCITE-3100: - Thanks for you contribution [~yuqi], reviewing now ~~ You can send a mail to dev mailing list to ask for the JIRA contribution permission :) > cast(? as DATE) won't work with PreparedStatement > - > > Key: CALCITE-3100 > URL: https://issues.apache.org/jira/browse/CALCITE-3100 > Project: Calcite > Issue Type: Bug >Reporter: Li Xian >Assignee: Danny Chan >Priority: Minor > Labels: pull-request-available > Time Spent: 10m > Remaining Estimate: 0h > > When I do something like > > {code:java} > Connection connection = > DriverManager.getConnection("jdbc:calcite:", info); > PreparedStatement ps = connection.prepareStatement("select * from EMPS where > JOINEDAT=cast(? as DATE)"); > ps.setString(1, "1996-08-03"); > ps.execute();{code} > > It will produce error like below > > {code:java} > java.sql.SQLException: exception while executing query: java.lang.String > cannot be cast to java.lang.Integer > at org.apache.calcite.avatica.Helper.createException(Helper.java:56) > at org.apache.calcite.avatica.Helper.createException(Helper.java:41) > at > org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:577) > at > org.apache.calcite.avatica.AvaticaPreparedStatement.execute(AvaticaPreparedStatement.java:239) > at org.apache.calcite.test.CsvTest.testDate(CsvTest.java:185) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) > at > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) > at > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) > at org.junit.runners.ParentRunner.run(ParentRunner.java:363) > at org.junit.runner.JUnitCore.run(JUnitCore.java:137) > at > com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) > at > com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) > at > com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) > at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) > Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to > java.lang.Integer > at Baz$1$1.moveNext(Unknown Source) > at > org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.(Linq4j.java:675) > at org.apache.calcite.linq4j.Linq4j.enumeratorIterator(Linq4j.java:95) > at > org.apache.calcite.linq4j.AbstractEnumerable.iterator(AbstractEnumerable.java:33) > at org.apache.calcite.avatica.MetaImpl.createCursor(MetaImpl.java:90) > at > org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:184) > at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:64) > at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:43) > at > org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:573) > ... 24 more > {code} > > It looks like that the 'cast' clause doesn't make effect here with the '?' > placeholder parameter. > I am able to reproduce this error by adding the below testcase to > org.apache.calcite.test.CsvTest and run it > {code:java} > @Test > public void testDate() throws Exception { > Properties info = new Properties(); > info.put("model", jsonPath("model")); > Connection connection = > DriverManager.getConnection("jdbc:calcite:", info); > PreparedStatement ps = connection.prepareStatement("select * from EMPS > where JOINEDAT=cast(? as DATE)"); > ps.setString(1, "1996-08-03"); > ps.execute(); > } > {c