[jira] [Created] (CALCITE-3842) Simplification of OR condition is based on order of operands.
anjali shrishrimal created CALCITE-3842: --- Summary: Simplification of OR condition is based on order of operands. Key: CALCITE-3842 URL: https://issues.apache.org/jira/browse/CALCITE-3842 Project: Calcite Issue Type: Bug Components: core Reporter: anjali shrishrimal RexSimplify simplifies : {noformat} (a <= 10) OR (a <= 1) --> a <= 10{noformat} but does not simplify {noformat} (a <= 1) OR (a <= 10) {noformat} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3806) How to optimize repeated RelNode Structures ?
anjali shrishrimal created CALCITE-3806: --- Summary: How to optimize repeated RelNode Structures ? Key: CALCITE-3806 URL: https://issues.apache.org/jira/browse/CALCITE-3806 Project: Calcite Issue Type: Wish Components: core Reporter: anjali shrishrimal Let's say input structure looks like this : {noformat} LogicalUnion(all=[true]) LogicalProject(EMPNO=[$0]) LogicalFilter(condition=[>=($0, 7369)]) LogicalTableScan(table=[[scott, EMP]]) LogicalProject(EMPNO=[$0]) LogicalFilter(condition=[>=($0, 7369)]) LogicalTableScan(table=[[scott, EMP]]){noformat} In this case, {noformat} LogicalProject(EMPNO=[$0]) LogicalFilter(condition=[>=($0, 7369)]) LogicalTableScan(table=[[scott, EMP]]){noformat} is repeated. It is going to fetch same data twice. Can we save one fetch? Can we somehow tell 2nd input of union to make use of union's 1st input. Is there any way to express that in plan? Also, If the structure was like this : {noformat} LogicalUnion(all=[true]) LogicalProject(EMPNO=[$0]) LogicalFilter(condition=[>=($0, 7369)]) LogicalTableScan(table=[[scott, EMP]]) LogicalProject(EMPNO=[$0]) LogicalFilter(condition=[>=($0, 8000)]) LogicalTableScan(table=[[scott, EMP]]){noformat} Second part of union can perform filtering on fetched data of 1st part. (As second's output is subset of first's output) Does calcite provide such kind of optimizations ? If not, what are the challenges to do so? I would appreciate some comments on this. Thank you. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3761) How to write a rule with optional intermediate operands?
anjali shrishrimal created CALCITE-3761: --- Summary: How to write a rule with optional intermediate operands? Key: CALCITE-3761 URL: https://issues.apache.org/jira/browse/CALCITE-3761 Project: Calcite Issue Type: Wish Components: core Reporter: anjali shrishrimal I want to write a rule to match a plan based on, only root/top RelNode and leaf RelNode, all Intermediate RelNodes are optional. What operands should be passed to such rule? Suppose Logical Plan is like given below. {code:java} LogicalRelNode4 LogicalRelNode3 (optional) LogicalRelNode2 (optional) LogicalRelNode1 {code} LogicalRelNode2 and LogicalRelNode3 are optional. Rule should match the structure irrespective to the presence of these optional Nodes. Rule should get matched for all the following structures. {code:java} 1. LogicalRelNode4 LogicalRelNode3 LogicalRelNode2 LogicalRelNode1 2. LogicalRelNode4 LogicalRelNode2 LogicalRelNode1 3. LogicalRelNode4 LogicalRelNode3 LogicalRelNode1 4. LogicalRelNode4 LogicalRelNode1 {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3624) Getting java.lang.NullPointerException at org.apache.calcite.schema.Schemas.queryable(Schemas.java:211)
anjali shrishrimal created CALCITE-3624: --- Summary: Getting java.lang.NullPointerException at org.apache.calcite.schema.Schemas.queryable(Schemas.java:211) Key: CALCITE-3624 URL: https://issues.apache.org/jira/browse/CALCITE-3624 Project: Calcite Issue Type: Bug Reporter: anjali shrishrimal I am creating a RelNode using RelBuilder. @Test public void testRun() throws Exception { FrameworkConfig frameworkConfig = config().build(); final RelBuilder builder = RelBuilder.create(frameworkConfig); String[] name = new String[]\{"ITEM", "ITEM"}; RelNode scan = builder.scan(name).build(); TranslatableTable items = (TranslatableTable)frameworkConfig.getDefaultSchema().getSubSchema("ITEM").getTable("ITEM"); scan = items.toRel(ViewExpanders.simpleContext(scan.getCluster()), scan.getTable()); RelNode level0RelNode = builder.push(scan) .filter( builder.call(SqlStdOperatorTable.AND, builder.call(SqlStdOperatorTable.EQUALS, builder.field("ITEM_ID"), builder.literal("AM_TestItem_21Aug17_0614")), builder.call(SqlStdOperatorTable.EQUALS, builder.field("OBJECT_TYPE"), builder.literal("Item")) ) ).build(); System.out.println(level0RelNode); try (PreparedStatement preparedStatement = RelRunners.run(level0RelNode)) { System.out.println(""); System.out.println(preparedStatement.toString()); System.out.println(""); String s = CalciteAssert.toString(preparedStatement.executeQuery()); System.out.println(""); System.out.println(s); } public static Frameworks.ConfigBuilder config() { CalciteSchema rootSchema1 = CalciteSchema.createRootSchema(true); rootSchema1 = rootSchema1.add("ITEM", new MySchema()); // MySchema consists of Map of MyTable which extends AbstractQueryableTable and implements TranslatableTable return Frameworks.newConfigBuilder().defaultSchema(rootSchema1.plus()); } } public static Frameworks.ConfigBuilder config() { CalciteSchema rootSchema1 = CalciteSchema.createRootSchema(true); rootSchema1 = rootSchema1.add("ITEM", new MySchema()); // MySchema consists of Map of MyTable which extends AbstractQueryableTable and implements TranslatableTable return Frameworks.newConfigBuilder().defaultSchema(rootSchema1.plus()); } I am getting following exception while executing a query. java.sql.SQLException: exception while executing query: nulljava.sql.SQLException: exception while executing query: null 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.executeQuery(AvaticaPreparedStatement.java:137) at org.apache.calcite.test.TeamcenterTest.testRun2(TeamcenterTest.java:372) 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.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:539) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:761) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:461) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:207)Caused by: java.lang.NullPointerException at org.apache.calcite.schema.Schemas.queryable(Schemas.java:211) at Baz.bind(Unknown Source) at
[jira] [Created] (CALCITE-3600) Rule to solve the filter partially by end application and remaining by calcite
anjali shrishrimal created CALCITE-3600: --- Summary: Rule to solve the filter partially by end application and remaining by calcite Key: CALCITE-3600 URL: https://issues.apache.org/jira/browse/CALCITE-3600 Project: Calcite Issue Type: Wish Reporter: anjali shrishrimal Add Rule to check if filter condition is solvable by end application. If part of the filter condition can be solved by end application, then it should get pushed to end application, and remaining part which can not be solved by end application, should get solved by calcite secondarily (i.e. upon fetch remove unwanted data as per filter condition) Consider an application which can solve only limited operators while filtering, say "=,<,>" and can not solve operator 'LIKE'. Example, filter condition is "id > 1000 AND name LIKE '%an%'" we would like to restrict the condition passed to application to "id > 1000" and remaining part "name LIKE '%an%'" should get solved by calcite. (The way it does for csv-adapter) To replicate the situation, consider test-case testFilter in MongoAdapterTest (org.apache.calcite.adapter.mongodb.MongoAdapterTest) of mongo-adapter. And modify it like below: @Test public void testFilter() { assertModel(MODEL) .query("select state, city from zips where state = 'CA' AND city LIKE '%E%'") .returnsUnordered("STATE=CA; CITY=LOS ANGELES", "STATE=CA; CITY=BELL GARDENS"); } Expected output of above query : STATE=CA; CITY=LOS ANGELES, STATE=CA; CITY=BELL GARDENS Expected plan : EnumerableFilter(condition=[LIKE(CAST(ITEM($0, 'city')):VARCHAR(20), '%E%')]) {{MongoToEnumerableConverter}} {{MongoProject(STATE=[CAST(ITEM($0, 'state')):VARCHAR(2)], CITY=[CAST(ITEM($0, 'city')):VARCHAR(20)])}} {{MongoFilter(condition=[=(CAST(ITEM($0, 'state')):VARCHAR(2), 'CA')])}} {{MongoTableScan(table=[[mongo_raw, zips]])}} -- This message was sent by Atlassian Jira (v8.3.4#803005)