[jira] [Created] (CALCITE-2123) Bug in the Druid Filter Translation when Comparing String Ref to a Constant Number
slim bouguerra created CALCITE-2123: --- Summary: Bug in the Druid Filter Translation when Comparing String Ref to a Constant Number Key: CALCITE-2123 URL: https://issues.apache.org/jira/browse/CALCITE-2123 Project: Calcite Issue Type: Bug Components: druid Reporter: slim bouguerra Assignee: Julian Hyde The following query {code} SELECT COUNT(*) FROM \"foodmart\" WHERE \"product_id\" = 16.0{code} Translates to a Druid Table Scan with a String to String Selector comparison filter. instead we need to have a Bound filter that cast the String to number. This is what we should expect. {code} {"type":"bound","dimension":"product_id","lower":"16.0","lowerStrict":false,"upper":"16.0","upperStrict":false,"ordering":"numeric"} {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (CALCITE-2009) Possible bug in interpreting ( IN ) OR ( IN ) logic
[ https://issues.apache.org/jira/browse/CALCITE-2009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313931#comment-16313931 ] Julian Hyde commented on CALCITE-2009: -- This is surprising because view expansion is usually reliable. (I'm not saying you're wrong. Just that an obvious cause doesn't spring to mind.) Have you had any luck creating a test case on other data sets? It's hard to make progress without access to your schema. > Possible bug in interpreting ( IN ) OR ( IN ) logic > - > > Key: CALCITE-2009 > URL: https://issues.apache.org/jira/browse/CALCITE-2009 > Project: Calcite > Issue Type: Bug >Affects Versions: 1.14.0, 1.13.0, 1.15.0 >Reporter: Piotr Bojko >Assignee: Julian Hyde > Fix For: 1.16.0 > > Attachments: logs-when-or-is-used.log, logs-when-union-is-used.log > > > I have schema > {code:javascript} > { > "version": "1.0", > "defaultSchema": "JIRA", > "schemas": [ > { > "name": "INTERNAL", > "type": "custom", > "factory": "%%UNDERLYING_SCHEMA_FACTORY", > "operand": {} > }, { > "name": "JIRA", > "type": "custom", > "factory": > "org.apache.calcite.schema.impl.AbstractSchema$Factory", > "operand": {}, > "tables": [ > { > "name": "ISSUES", > "type": "view", > "sql": [ > "SELECT JI.ID, JI.SUMMARY, > JI.PROJECT ", > "FROM INTERNAL.JIRAISSUE as JI > ", > "WHERE JI.ID IN (SELECT EAI.ID > FROM EXPLICIT_ALLOWED_ISSUES AS EAI) ", > "UNION ", > "SELECT JI.ID, JI.SUMMARY, > JI.PROJECT ", > "FROM INTERNAL.JIRAISSUE as JI > ", > "WHERE JI.PROJECT IN (SELECT > AP.ID FROM ALLOWED_PROJECTS AS AP)" > ] > }, > { > "name": "ALLOWED_PROJECTS", > "type": "table", > "factory": "%%DELEGATING_TABLE_FACTORY" > }, > { > "name": "EXPLICIT_ALLOWED_ISSUES", > "type": "table", > "factory": "%%DELEGATING_TABLE_FACTORY" > } > ] > } > ] > } > {code} > Where INTERNAL schema points to JDBC native JIRA Schema (through my custom > factory, but it only wraps passing datasource instead of user/password/url to > db) and JIRA schema has one view and two tables (factories generate java data > wrapped in AbstractQueryableTable) > When running "SELECT * FROM ISSUES" all works. > But when changing the view from UNION construction to OR - engine provides no > results: > {code:javascript} > { > "version": "1.0", > "defaultSchema": "JIRA", > "schemas": [ > { > "name": "INTERNAL", > "type": "custom", > "factory": "%%UNDERLYING_SCHEMA_FACTORY", > "operand": {} > }, { > "name": "JIRA", > "type": "custom", > "factory": > "org.apache.calcite.schema.impl.AbstractSchema$Factory", > "operand": {}, > "tables": [ > { > "name": "ISSUES", > "type": "view", > "sql": [ > "SELECT JI.ID, JI.SUMMARY, > JI.PROJECT ", > "FROM INTERNAL.JIRAISSUE as JI > ", > "WHERE JI.ID IN (SELECT EAI.ID > FROM EXPLICIT_ALLOWED_ISSUES AS EAI) ", > "OR (JI.PROJECT IN (SELECT > AP.ID FROM ALLOWED_PROJECTS AS AP))" > ] > }, > { > "name": "ALLOWED_PROJECTS", >
[jira] [Commented] (CALCITE-2121) CAST timestamp with time zone to SQL VARCHAR
[ https://issues.apache.org/jira/browse/CALCITE-2121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313920#comment-16313920 ] Julian Hyde commented on CALCITE-2121: -- Also, CALCITE-2107. > CAST timestamp with time zone to SQL VARCHAR > > > Key: CALCITE-2121 > URL: https://issues.apache.org/jira/browse/CALCITE-2121 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: slim bouguerra >Assignee: Julian Hyde > > Running the following test at org.apache.calcite.test.DruidAdapterIT > {code} > @Test > public void testCastTimestampWithTimeZone() { > final String sql = "SELECT CAST(\"timestamp\" AS VARCHAR) FROM > \"foodmart\""; > sql(sql, FOODMART).runs(); > } > {code} > leads to > {code} > 2018-01-05 09:56:57,358 [main] ERROR - > org.apache.calcite.sql.validate.SqlValidatorException: Cast function cannot > convert value of type TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > 2018-01-05 09:56:57,360 [main] ERROR - > org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to > line 1, column 35: Cast function cannot convert value of type > TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > java.lang.RuntimeException: exception while executing [SELECT > CAST("timestamp" AS VARCHAR) FROM "foodmart"] > at > org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1411) > at > org.apache.calcite.test.DruidAdapterIT.testCastTimestampWithTimeZone(DruidAdapterIT.java:3503) > 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.RuntimeException: With materializationsEnabled=false, > limit=0 > at > org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:600) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1407) > ... 23 more > Caused by: java.sql.SQLException: Error while executing SQL "SELECT > CAST("timestamp" AS VARCHAR) FROM "foodmart"": From line 1, column 8 to line > 1, column 35: Cast function cannot convert value of type > TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > 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.AvaticaStatement.executeInternal(AvaticaStatement.java:156) > at > org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) > at > org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:568) > ... 24 more > Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, > column 8 to line 1, column 35: Cast function cannot convert value of type > TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > at >
[jira] [Commented] (CALCITE-2121) CAST timestamp with time zone to SQL VARCHAR
[ https://issues.apache.org/jira/browse/CALCITE-2121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313917#comment-16313917 ] Julian Hyde commented on CALCITE-2121: -- Yes, it's valid. Another way to look at the problem is that we added a new data type in CALCITE-1947, there is a lot of work to make sure that a type works in all circumstances, and we've not yet finished that work. Some areas to look at: * Consider adding a column to ReflectiveSchema.everyTypes, and search for tests that use it; * Read through SqlOperatorBaseTest for tests that test every type (e.g. cast types to and from string); * See SqlValidatorTest.testCastFails; * Search for other tests that use TIMESTAMP and seem to be operating on all types; * We don't have an equivalent function to CURRENT_TIMESTAMP that produces a TIMESTAMP WITH LOCAL TIME ZONE; * Also check CALCITE-1784 and mark it fixed if it's fixed. > CAST timestamp with time zone to SQL VARCHAR > > > Key: CALCITE-2121 > URL: https://issues.apache.org/jira/browse/CALCITE-2121 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: slim bouguerra >Assignee: Julian Hyde > > Running the following test at org.apache.calcite.test.DruidAdapterIT > {code} > @Test > public void testCastTimestampWithTimeZone() { > final String sql = "SELECT CAST(\"timestamp\" AS VARCHAR) FROM > \"foodmart\""; > sql(sql, FOODMART).runs(); > } > {code} > leads to > {code} > 2018-01-05 09:56:57,358 [main] ERROR - > org.apache.calcite.sql.validate.SqlValidatorException: Cast function cannot > convert value of type TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > 2018-01-05 09:56:57,360 [main] ERROR - > org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to > line 1, column 35: Cast function cannot convert value of type > TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > java.lang.RuntimeException: exception while executing [SELECT > CAST("timestamp" AS VARCHAR) FROM "foodmart"] > at > org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1411) > at > org.apache.calcite.test.DruidAdapterIT.testCastTimestampWithTimeZone(DruidAdapterIT.java:3503) > 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.RuntimeException: With materializationsEnabled=false, > limit=0 > at > org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:600) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1407) > ... 23 more > Caused by: java.sql.SQLException: Error while executing SQL "SELECT > CAST("timestamp" AS VARCHAR) FROM "foodmart"": From line 1, column 8 to line > 1, column 35: Cast function cannot convert value of type > TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > at org.apache.calcite.avatica.Helper.createException(Helper.java:56) > at org.apache.calcite.avatica.Helper.createException(Helper.java:41) > at >
[jira] [Commented] (CALCITE-1658) DateRangeRules issues
[ https://issues.apache.org/jira/browse/CALCITE-1658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313675#comment-16313675 ] slim bouguerra commented on CALCITE-1658: - [~julianhyde] I have created new JIRA Case here https://issues.apache.org/jira/browse/CALCITE-2122. Also not sure if this is related to the actual rule. > DateRangeRules issues > - > > Key: CALCITE-1658 > URL: https://issues.apache.org/jira/browse/CALCITE-1658 > Project: Calcite > Issue Type: Bug > Components: core, druid >Reporter: Gian Merlino >Assignee: Nishant Bangarwa > Fix For: 1.16.0 > > > Follow up to CALCITE-1601. In Druid's built in SQL module (not the Druid > adapter in Calcite), some unit tests fail when DateRangeRules.FILTER_INSTANCE > is enabled. These include the SQLs below. In all cases, the predicate was > incorrectly simplified to "false" and no Druid queries were made. > Removing DateRangeRules from the planner causes the results to be correct. > {code} > SELECT COUNT(*) FROM druid.foo > WHERE >(EXTRACT(YEAR FROM __time) = 2000 AND EXTRACT(MONTH FROM __time) IN > (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > {code} > {code} > SELECT COUNT(*) FROM druid.foo > WHERE > EXTRACT(YEAR FROM __time) IN (2000, 2001) AND ( (EXTRACT(YEAR FROM > __time) = 2000 AND EXTRACT(MONTH FROM __time) IN (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > ) > {code} > {code} > SELECT COUNT(*) FROM druid.foo > WHERE > EXTRACT(YEAR FROM __time) <> 2000 AND ( (EXTRACT(YEAR FROM __time) = > 2000 AND EXTRACT(MONTH FROM __time) IN (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > ) > {code} > {code} > SELECT COUNT(*) FROM druid.foo > WHERE > EXTRACT(MONTH FROM __time) IN (1, 2, 3, 5) AND ( (EXTRACT(YEAR FROM > __time) = 2000 AND EXTRACT(MONTH FROM __time) IN (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > ) > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (CALCITE-1658) DateRangeRules issues
[ https://issues.apache.org/jira/browse/CALCITE-1658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313667#comment-16313667 ] Julian Hyde commented on CALCITE-1658: -- Can you add the following tests as part of your fix. We don't test {{cast('-mm-dd' as timestamp)}} anywhere outside of DruidAdapterIT currently. {noformat} diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java index e1c9e9c..19c722d 100644 --- a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java +++ b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java @@ -1320,6 +1320,14 @@ private void checkCastToString(String value, String type, String expected) { "cast('1945-02-24 12:42:25.34' as TIMESTAMP)", "1945-02-24 12:42:25", "TIMESTAMP(0) NOT NULL"); +tester.checkScalar( +"cast('1945-12-31' as TIMESTAMP)", +"1945-12-31 00:00:00", +"TIMESTAMP(0) NOT NULL"); +tester.checkScalar( +"cast('2004-02-29' as TIMESTAMP)", +"2004-02-29 00:00:00", +"TIMESTAMP(0) NOT NULL"); if (Bug.FRG282_FIXED) { tester.checkScalar( diff --git a/core/src/test/resources/sql/misc.iq b/core/src/test/resources/sql/misc.iq index 9a79bb7..e32ffbf 100644 --- a/core/src/test/resources/sql/misc.iq +++ b/core/src/test/resources/sql/misc.iq @@ -1508,7 +1508,7 @@ select (case when (true) then 1 end) from (values(1)); EXPR$0 INTEGER(10) !type -# Cast an character literal to a timestamp; note: the plan does not contain CAST +# Cast a character literal to a timestamp; note: the plan does not contain CAST values cast('1969-07-21 12:34:56' as timestamp); +-+ | EXPR$0 | @@ -1522,6 +1522,20 @@ EnumerableCalc(expr#0=[{inputs}], expr#1=[1969-07-21 12:34:56], EXPR$0=[$t1]) EnumerableValues(tuples=[[{ 0 }]]) !plan +# Cast a character literal without time to a timestamp; note: the plan does not contain CAST +values cast('1969-07-21' as timestamp); ++-+ +| EXPR$0 | ++-+ +| 1969-07-21 00:00:00 | ++-+ +(1 row) + +!ok +EnumerableCalc(expr#0=[{inputs}], expr#1=[1969-07-21 00:00:00], EXPR$0=[$t1]) + EnumerableValues(tuples=[[{ 0 }]]) +!plan + # Cast a character literal to a date; note: the plan does not contain CAST values cast('1969-07-21' as date); ++ {noformat} > DateRangeRules issues > - > > Key: CALCITE-1658 > URL: https://issues.apache.org/jira/browse/CALCITE-1658 > Project: Calcite > Issue Type: Bug > Components: core, druid >Reporter: Gian Merlino >Assignee: Nishant Bangarwa > Fix For: 1.16.0 > > > Follow up to CALCITE-1601. In Druid's built in SQL module (not the Druid > adapter in Calcite), some unit tests fail when DateRangeRules.FILTER_INSTANCE > is enabled. These include the SQLs below. In all cases, the predicate was > incorrectly simplified to "false" and no Druid queries were made. > Removing DateRangeRules from the planner causes the results to be correct. > {code} > SELECT COUNT(*) FROM druid.foo > WHERE >(EXTRACT(YEAR FROM __time) = 2000 AND EXTRACT(MONTH FROM __time) IN > (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > {code} > {code} > SELECT COUNT(*) FROM druid.foo > WHERE > EXTRACT(YEAR FROM __time) IN (2000, 2001) AND ( (EXTRACT(YEAR FROM > __time) = 2000 AND EXTRACT(MONTH FROM __time) IN (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > ) > {code} > {code} > SELECT COUNT(*) FROM druid.foo > WHERE > EXTRACT(YEAR FROM __time) <> 2000 AND ( (EXTRACT(YEAR FROM __time) = > 2000 AND EXTRACT(MONTH FROM __time) IN (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > ) > {code} > {code} > SELECT COUNT(*) FROM druid.foo > WHERE > EXTRACT(MONTH FROM __time) IN (1, 2, 3, 5) AND ( (EXTRACT(YEAR FROM > __time) = 2000 AND EXTRACT(MONTH FROM __time) IN (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > ) > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Resolved] (CALCITE-2120) Request to support of Oracle database as meta data store for Druid
[ https://issues.apache.org/jira/browse/CALCITE-2120?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Julian Hyde resolved CALCITE-2120. -- Resolution: Invalid Agreed. Marking invalid. > Request to support of Oracle database as meta data store for Druid > -- > > Key: CALCITE-2120 > URL: https://issues.apache.org/jira/browse/CALCITE-2120 > Project: Calcite > Issue Type: New Feature > Components: druid >Reporter: vaibhav >Assignee: Julian Hyde > > Currently MySQL, Postgres, and Derby are supported as Druid metadata stores. > Request to support of Oracle database as meta data store for Druid. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (CALCITE-2120) Request to support of Oracle database as meta data store for Druid
[ https://issues.apache.org/jira/browse/CALCITE-2120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313621#comment-16313621 ] slim bouguerra commented on CALCITE-2120: - I don't think this is the place to raise this JIRA case. Druid has a GitHub issue page. https://github.com/druid-io/druid/issues FYI there was some related work on this but it is aborted https://github.com/druid-io/druid/pull/5053. > Request to support of Oracle database as meta data store for Druid > -- > > Key: CALCITE-2120 > URL: https://issues.apache.org/jira/browse/CALCITE-2120 > Project: Calcite > Issue Type: New Feature > Components: druid >Reporter: vaibhav >Assignee: Julian Hyde > > Currently MySQL, Postgres, and Derby are supported as Druid metadata stores. > Request to support of Oracle database as meta data store for Druid. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (CALCITE-2122) Continuum of DateRangeRules issues.
[ https://issues.apache.org/jira/browse/CALCITE-2122?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] slim bouguerra updated CALCITE-2122: Component/s: core > Continuum of DateRangeRules issues. > --- > > Key: CALCITE-2122 > URL: https://issues.apache.org/jira/browse/CALCITE-2122 > Project: Calcite > Issue Type: Bug > Components: core, druid >Reporter: slim bouguerra >Assignee: Julian Hyde > > The following test at org.apache.calcite.test.DruidAdapterIT > {code} > @Test > public void testCombinationOfValidAndNotValidAndInterval() { > final String sql = "SELECT COUNT(*) FROM \"foodmart\" " > + "WHERE \"timestamp\" < CAST('1997-01-02' as TIMESTAMP) AND " > + "EXTRACT(MONTH FROM \"timestamp\") = 01 AND EXTRACT(YEAR FROM > \"timestamp\") = 01 "; > sql(sql, FOODMART) > .runs(); > } > {code} > Leads to > {code} > java.lang.RuntimeException: exception while executing [SELECT COUNT(*) FROM > "foodmart" WHERE "timestamp" < CAST('1997-01-02' as TIMESTAMP) AND > EXTRACT(MONTH FROM "timestamp") = 01 AND EXTRACT(YEAR FROM "timestamp") = 01 ] > at > org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1411) > at > org.apache.calcite.test.DruidAdapterIT.testCombinationOfValidAndNotValidAndInterval(DruidAdapterIT.java:3497) > 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.RuntimeException: With materializationsEnabled=false, > limit=0 > at > org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:600) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1407) > ... 23 more > Caused by: java.sql.SQLException: Error while executing SQL "SELECT COUNT(*) > FROM "foodmart" WHERE "timestamp" < CAST('1997-01-02' as TIMESTAMP) AND > EXTRACT(MONTH FROM "timestamp") = 01 AND EXTRACT(YEAR FROM "timestamp") = 01 > ": Error while applying rule FilterDateRangeRule, args > [rel#19:LogicalFilter.NONE.[](input=rel#18:Subset#0.BINDABLE.[],condition=AND(<($0, > CAST('1997-01-02'):TIMESTAMP(0) NOT NULL), =(EXTRACT(FLAG(MONTH), $0), 1), > =(EXTRACT(FLAG(YEAR), $0), 1)))] > 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.AvaticaStatement.executeInternal(AvaticaStatement.java:156) > at > org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) > at > org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:568) > ... 24 more > Caused by: java.lang.RuntimeException: Error while applying rule > FilterDateRangeRule, args > [rel#19:LogicalFilter.NONE.[](input=rel#18:Subset#0.BINDABLE.[],condition=AND(<($0, > CAST('1997-01-02'):TIMESTAMP(0) NOT NULL), =(EXTRACT(FLAG(MONTH), $0), 1), > =(EXTRACT(FLAG(YEAR), $0), 1)))] > at >
[jira] [Commented] (CALCITE-2121) CAST timestamp with time zone to SQL VARCHAR
[ https://issues.apache.org/jira/browse/CALCITE-2121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313579#comment-16313579 ] slim bouguerra commented on CALCITE-2121: - FYI [~jcamachorodriguez] this is a Timezone related issue. I think is a valid cast since {code} "SELECT CAST(CAST(\"timestamp\" AS TIMESTAMP) AS VARCHAR) FROM \"foodmart\""{code} works fine. > CAST timestamp with time zone to SQL VARCHAR > > > Key: CALCITE-2121 > URL: https://issues.apache.org/jira/browse/CALCITE-2121 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: slim bouguerra >Assignee: Julian Hyde > > Running the following test at org.apache.calcite.test.DruidAdapterIT > {code} > @Test > public void testCastTimestampWithTimeZone() { > final String sql = "SELECT CAST(\"timestamp\" AS VARCHAR) FROM > \"foodmart\""; > sql(sql, FOODMART).runs(); > } > {code} > leads to > {code} > 2018-01-05 09:56:57,358 [main] ERROR - > org.apache.calcite.sql.validate.SqlValidatorException: Cast function cannot > convert value of type TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > 2018-01-05 09:56:57,360 [main] ERROR - > org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to > line 1, column 35: Cast function cannot convert value of type > TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > java.lang.RuntimeException: exception while executing [SELECT > CAST("timestamp" AS VARCHAR) FROM "foodmart"] > at > org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1411) > at > org.apache.calcite.test.DruidAdapterIT.testCastTimestampWithTimeZone(DruidAdapterIT.java:3503) > 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.RuntimeException: With materializationsEnabled=false, > limit=0 > at > org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:600) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1407) > ... 23 more > Caused by: java.sql.SQLException: Error while executing SQL "SELECT > CAST("timestamp" AS VARCHAR) FROM "foodmart"": From line 1, column 8 to line > 1, column 35: Cast function cannot convert value of type > TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > 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.AvaticaStatement.executeInternal(AvaticaStatement.java:156) > at > org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) > at > org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:568) > ... 24 more > Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, > column 8 to line 1, column 35: Cast function cannot convert value of type > TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR > at
[jira] [Created] (CALCITE-2122) Continuum of DateRangeRules issues.
slim bouguerra created CALCITE-2122: --- Summary: Continuum of DateRangeRules issues. Key: CALCITE-2122 URL: https://issues.apache.org/jira/browse/CALCITE-2122 Project: Calcite Issue Type: Bug Components: druid Reporter: slim bouguerra Assignee: Julian Hyde The following test at org.apache.calcite.test.DruidAdapterIT {code} @Test public void testCombinationOfValidAndNotValidAndInterval() { final String sql = "SELECT COUNT(*) FROM \"foodmart\" " + "WHERE \"timestamp\" < CAST('1997-01-02' as TIMESTAMP) AND " + "EXTRACT(MONTH FROM \"timestamp\") = 01 AND EXTRACT(YEAR FROM \"timestamp\") = 01 "; sql(sql, FOODMART) .runs(); } {code} Leads to {code} java.lang.RuntimeException: exception while executing [SELECT COUNT(*) FROM "foodmart" WHERE "timestamp" < CAST('1997-01-02' as TIMESTAMP) AND EXTRACT(MONTH FROM "timestamp") = 01 AND EXTRACT(YEAR FROM "timestamp") = 01 ] at org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1411) at org.apache.calcite.test.DruidAdapterIT.testCombinationOfValidAndNotValidAndInterval(DruidAdapterIT.java:3497) 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.RuntimeException: With materializationsEnabled=false, limit=0 at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:600) at org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1407) ... 23 more Caused by: java.sql.SQLException: Error while executing SQL "SELECT COUNT(*) FROM "foodmart" WHERE "timestamp" < CAST('1997-01-02' as TIMESTAMP) AND EXTRACT(MONTH FROM "timestamp") = 01 AND EXTRACT(YEAR FROM "timestamp") = 01 ": Error while applying rule FilterDateRangeRule, args [rel#19:LogicalFilter.NONE.[](input=rel#18:Subset#0.BINDABLE.[],condition=AND(<($0, CAST('1997-01-02'):TIMESTAMP(0) NOT NULL), =(EXTRACT(FLAG(MONTH), $0), 1), =(EXTRACT(FLAG(YEAR), $0), 1)))] 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.AvaticaStatement.executeInternal(AvaticaStatement.java:156) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:568) ... 24 more Caused by: java.lang.RuntimeException: Error while applying rule FilterDateRangeRule, args [rel#19:LogicalFilter.NONE.[](input=rel#18:Subset#0.BINDABLE.[],condition=AND(<($0, CAST('1997-01-02'):TIMESTAMP(0) NOT NULL), =(EXTRACT(FLAG(MONTH), $0), 1), =(EXTRACT(FLAG(YEAR), $0), 1)))] at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:236) at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:650) at org.apache.calcite.tools.Programs$5.run(Programs.java:326) at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:387)
[jira] [Created] (CALCITE-2121) CAST timestamp with time zone to SQL VARCHAR
slim bouguerra created CALCITE-2121: --- Summary: CAST timestamp with time zone to SQL VARCHAR Key: CALCITE-2121 URL: https://issues.apache.org/jira/browse/CALCITE-2121 Project: Calcite Issue Type: Bug Components: core Reporter: slim bouguerra Assignee: Julian Hyde Running the following test at org.apache.calcite.test.DruidAdapterIT {code} @Test public void testCastTimestampWithTimeZone() { final String sql = "SELECT CAST(\"timestamp\" AS VARCHAR) FROM \"foodmart\""; sql(sql, FOODMART).runs(); } {code} leads to {code} 2018-01-05 09:56:57,358 [main] ERROR - org.apache.calcite.sql.validate.SqlValidatorException: Cast function cannot convert value of type TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR 2018-01-05 09:56:57,360 [main] ERROR - org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to line 1, column 35: Cast function cannot convert value of type TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR java.lang.RuntimeException: exception while executing [SELECT CAST("timestamp" AS VARCHAR) FROM "foodmart"] at org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1411) at org.apache.calcite.test.DruidAdapterIT.testCastTimestampWithTimeZone(DruidAdapterIT.java:3503) 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.RuntimeException: With materializationsEnabled=false, limit=0 at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:600) at org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1407) ... 23 more Caused by: java.sql.SQLException: Error while executing SQL "SELECT CAST("timestamp" AS VARCHAR) FROM "foodmart"": From line 1, column 8 to line 1, column 35: Cast function cannot convert value of type TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR 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.AvaticaStatement.executeInternal(AvaticaStatement.java:156) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:568) ... 24 more Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to line 1, column 35: Cast function cannot convert value of type TIMESTAMP_WITH_LOCAL_TIME_ZONE(0) to type VARCHAR at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at
[jira] [Commented] (CALCITE-1658) DateRangeRules issues
[ https://issues.apache.org/jira/browse/CALCITE-1658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313561#comment-16313561 ] Julian Hyde commented on CALCITE-1658: -- A new case, please. > DateRangeRules issues > - > > Key: CALCITE-1658 > URL: https://issues.apache.org/jira/browse/CALCITE-1658 > Project: Calcite > Issue Type: Bug > Components: core, druid >Reporter: Gian Merlino >Assignee: Nishant Bangarwa > Fix For: 1.16.0 > > > Follow up to CALCITE-1601. In Druid's built in SQL module (not the Druid > adapter in Calcite), some unit tests fail when DateRangeRules.FILTER_INSTANCE > is enabled. These include the SQLs below. In all cases, the predicate was > incorrectly simplified to "false" and no Druid queries were made. > Removing DateRangeRules from the planner causes the results to be correct. > {code} > SELECT COUNT(*) FROM druid.foo > WHERE >(EXTRACT(YEAR FROM __time) = 2000 AND EXTRACT(MONTH FROM __time) IN > (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > {code} > {code} > SELECT COUNT(*) FROM druid.foo > WHERE > EXTRACT(YEAR FROM __time) IN (2000, 2001) AND ( (EXTRACT(YEAR FROM > __time) = 2000 AND EXTRACT(MONTH FROM __time) IN (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > ) > {code} > {code} > SELECT COUNT(*) FROM druid.foo > WHERE > EXTRACT(YEAR FROM __time) <> 2000 AND ( (EXTRACT(YEAR FROM __time) = > 2000 AND EXTRACT(MONTH FROM __time) IN (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > ) > {code} > {code} > SELECT COUNT(*) FROM druid.foo > WHERE > EXTRACT(MONTH FROM __time) IN (1, 2, 3, 5) AND ( (EXTRACT(YEAR FROM > __time) = 2000 AND EXTRACT(MONTH FROM __time) IN (2, 3, 5)) > OR (EXTRACT(YEAR FROM __time) = 2001 AND EXTRACT(MONTH FROM __time) = 1) > ) > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (CALCITE-1658) DateRangeRules issues
[ https://issues.apache.org/jira/browse/CALCITE-1658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313510#comment-16313510 ] slim bouguerra commented on CALCITE-1658: - [~julianhyde] and [~nishantbangarwa] this simple test is failing and I think it is related to this patch. Should i open new JIRA case or reopen this one? {code} @Test public void testCombinationOfValidAndNotValidAndInterval() { final String sql = "SELECT COUNT(*) FROM \"foodmart\" " + "WHERE \"timestamp\" < CAST('1997-01-02' as TIMESTAMP) AND " + "EXTRACT(MONTH FROM \"timestamp\") = 01 AND EXTRACT(YEAR FROM \"timestamp\") = 01 "; sql(sql, FOODMART) .runs(); } {code} Stack {code} java.lang.RuntimeException: exception while executing [SELECT COUNT(*) FROM "foodmart" WHERE "timestamp" < CAST('1997-01-02' as TIMESTAMP) AND EXTRACT(MONTH FROM "timestamp") = 01 AND EXTRACT(YEAR FROM "timestamp") = 01 ] at org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1411) at org.apache.calcite.test.DruidAdapterIT.testCombinationOfValidAndNotValidAndInterval(DruidAdapterIT.java:3497) 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.RuntimeException: With materializationsEnabled=false, limit=0 at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:600) at org.apache.calcite.test.CalciteAssert$AssertQuery.runs(CalciteAssert.java:1407) ... 23 more Caused by: java.sql.SQLException: Error while executing SQL "SELECT COUNT(*) FROM "foodmart" WHERE "timestamp" < CAST('1997-01-02' as TIMESTAMP) AND EXTRACT(MONTH FROM "timestamp") = 01 AND EXTRACT(YEAR FROM "timestamp") = 01 ": Error while applying rule FilterDateRangeRule, args [rel#19:LogicalFilter.NONE.[](input=rel#18:Subset#0.BINDABLE.[],condition=AND(<($0, CAST('1997-01-02'):TIMESTAMP(0) NOT NULL), =(EXTRACT(FLAG(MONTH), $0), 1), =(EXTRACT(FLAG(YEAR), $0), 1)))] 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.AvaticaStatement.executeInternal(AvaticaStatement.java:156) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:568) ... 24 more Caused by: java.lang.RuntimeException: Error while applying rule FilterDateRangeRule, args [rel#19:LogicalFilter.NONE.[](input=rel#18:Subset#0.BINDABLE.[],condition=AND(<($0, CAST('1997-01-02'):TIMESTAMP(0) NOT NULL), =(EXTRACT(FLAG(MONTH), $0), 1), =(EXTRACT(FLAG(YEAR), $0), 1)))] at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:236) at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:650) at org.apache.calcite.tools.Programs$5.run(Programs.java:326) at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:387) at
[jira] [Commented] (CALCITE-2009) Possible bug in interpreting ( IN ) OR ( IN ) logic
[ https://issues.apache.org/jira/browse/CALCITE-2009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313218#comment-16313218 ] Piotr Bojko commented on CALCITE-2009: -- This issue is strictly dependent on to whether the table view (with in-or-in) is involved or the query does is raw (without tables view). Any hints would be appreciated > Possible bug in interpreting ( IN ) OR ( IN ) logic > - > > Key: CALCITE-2009 > URL: https://issues.apache.org/jira/browse/CALCITE-2009 > Project: Calcite > Issue Type: Bug >Affects Versions: 1.14.0, 1.13.0, 1.15.0 >Reporter: Piotr Bojko >Assignee: Julian Hyde > Fix For: 1.16.0 > > Attachments: logs-when-or-is-used.log, logs-when-union-is-used.log > > > I have schema > {code:javascript} > { > "version": "1.0", > "defaultSchema": "JIRA", > "schemas": [ > { > "name": "INTERNAL", > "type": "custom", > "factory": "%%UNDERLYING_SCHEMA_FACTORY", > "operand": {} > }, { > "name": "JIRA", > "type": "custom", > "factory": > "org.apache.calcite.schema.impl.AbstractSchema$Factory", > "operand": {}, > "tables": [ > { > "name": "ISSUES", > "type": "view", > "sql": [ > "SELECT JI.ID, JI.SUMMARY, > JI.PROJECT ", > "FROM INTERNAL.JIRAISSUE as JI > ", > "WHERE JI.ID IN (SELECT EAI.ID > FROM EXPLICIT_ALLOWED_ISSUES AS EAI) ", > "UNION ", > "SELECT JI.ID, JI.SUMMARY, > JI.PROJECT ", > "FROM INTERNAL.JIRAISSUE as JI > ", > "WHERE JI.PROJECT IN (SELECT > AP.ID FROM ALLOWED_PROJECTS AS AP)" > ] > }, > { > "name": "ALLOWED_PROJECTS", > "type": "table", > "factory": "%%DELEGATING_TABLE_FACTORY" > }, > { > "name": "EXPLICIT_ALLOWED_ISSUES", > "type": "table", > "factory": "%%DELEGATING_TABLE_FACTORY" > } > ] > } > ] > } > {code} > Where INTERNAL schema points to JDBC native JIRA Schema (through my custom > factory, but it only wraps passing datasource instead of user/password/url to > db) and JIRA schema has one view and two tables (factories generate java data > wrapped in AbstractQueryableTable) > When running "SELECT * FROM ISSUES" all works. > But when changing the view from UNION construction to OR - engine provides no > results: > {code:javascript} > { > "version": "1.0", > "defaultSchema": "JIRA", > "schemas": [ > { > "name": "INTERNAL", > "type": "custom", > "factory": "%%UNDERLYING_SCHEMA_FACTORY", > "operand": {} > }, { > "name": "JIRA", > "type": "custom", > "factory": > "org.apache.calcite.schema.impl.AbstractSchema$Factory", > "operand": {}, > "tables": [ > { > "name": "ISSUES", > "type": "view", > "sql": [ > "SELECT JI.ID, JI.SUMMARY, > JI.PROJECT ", > "FROM INTERNAL.JIRAISSUE as JI > ", > "WHERE JI.ID IN (SELECT EAI.ID > FROM EXPLICIT_ALLOWED_ISSUES AS EAI) ", > "OR (JI.PROJECT IN (SELECT > AP.ID FROM ALLOWED_PROJECTS AS AP))" > ] > }, > { > "name": "ALLOWED_PROJECTS", > "type": "table", > "factory":
[jira] [Comment Edited] (CALCITE-2009) Possible bug in interpreting ( IN ) OR ( IN ) logic
[ https://issues.apache.org/jira/browse/CALCITE-2009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313176#comment-16313176 ] Piotr Bojko edited comment on CALCITE-2009 at 1/5/18 2:18 PM: -- Update. The problem is somewhere at the SqlToRelConverter.convertQuery level. The query {code} select * from ISSUES {code} is resolved to {code} SELECT `JI`.`ID`, `JI`.`SUMMARY`, `JI`.`PROJECT`, `JI`.`ISSUENUM` AS `NUM`, `JI`.`CREATOR`, `JI`.`ASSIGNEE`, `JI`.`REPORTER`, `JI`.`CREATED`, `JI`.`UPDATED`, `JI`.`DUEDATE` AS `DUE`, `JI`.`RESOLUTIONDATE` AS `RESOLVED`, `JI`.`DESCRIPTION`, `JI`.`ENVIRONMENT`, `JI`.`ISSUETYPE` AS `TYPE`, `JI`.`PRIORITY`, `JI`.`RESOLUTION`, `JI`.`ISSUESTATUS` AS `STATUS`, `JI`.`SECURITY` AS `SECURITYLEVEL`, `JI`.`VOTES`, `JI`.`WATCHES`, `JI`.`TIMEORIGINALESTIMATE` AS `ORIGINALESTIMATE`, `JI`.`TIMEESTIMATE` AS `ESTIMATE`, `JI`.`TIMESPENT` FROM `INTERNAL`.`JIRAISSUE` AS `JI` WHERE `JI`.`ID` IN (SELECT `EAI`.`ID` FROM `EXPLICIT_ALLOWED_ISSUES` AS `EAI`) OR `JI`.`PROJECT` IN (SELECT `AP`.`ID` FROM `EXPLICIT_ALLOWED_PROJECTS` AS `AP`) {code} which is resolved to {code} LogicalProject(ID=[$0], SUMMARY=[$8], PROJECT=[$3], NUM=[$2], CREATOR=[$6], ASSIGNEE=[$5], REPORTER=[$4], CREATED=[$14], UPDATED=[$15], DUE=[$16], RESOLVED=[$17], DESCRIPTION=[$9], ENVIRONMENT=[$10], TYPE=[$7], PRIORITY=[$11], RESOLUTION=[$12], STATUS=[$13], SECURITYLEVEL=[$24], VOTES=[$18], WATCHES=[$19], ORIGINALESTIMATE=[$20], ESTIMATE=[$21], TIMESPENT=[$22]) LogicalFilter(condition=[OR(true, true)]) LogicalJoin(condition=[=($3, $28)], joinType=[inner]) LogicalJoin(condition=[=($0, $27)], joinType=[inner]) JdbcTableScan(table=[[INTERNAL, JIRAISSUE]]) LogicalAggregate(group=[{0}]) LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_ISSUES]]) LogicalAggregate(group=[{0}]) LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_PROJECTS]]) {code} which is invalid. but when passing resolved query (not using the declared view ISSUES) explicitly, plan resolves to: {code} LogicalProject(ID=[$0], SUMMARY=[$8], PROJECT=[$3], NUM=[$2], CREATOR=[$6], ASSIGNEE=[$5], REPORTER=[$4], CREATED=[$14], UPDATED=[$15], DUE=[$16], RESOLVED=[$17], DESCRIPTION=[$9], ENVIRONMENT=[$10], TYPE=[$7], PRIORITY=[$11], RESOLUTION=[$12], STATUS=[$13], SECURITYLEVEL=[$24], VOTES=[$18], WATCHES=[$19], ORIGINALESTIMATE=[$20], ESTIMATE=[$21], TIMESPENT=[$22]) LogicalFilter(condition=[OR(IN($0, {LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_ISSUES]]) }), IN($3, { LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_PROJECTS]]) }))]) JdbcTableScan(table=[[INTERNAL, JIRAISSUE]]) {code} which is valid. was (Author: ptrbojko): Update. The problem is somewhere at the SqlToRelConverter.convertQuery level. The query {code} select * from ISSUES {code} is resolved to {code} SELECT `JI`.`ID`, `JI`.`SUMMARY`, `JI`.`PROJECT`, `JI`.`ISSUENUM` AS `NUM`, `JI`.`CREATOR`, `JI`.`ASSIGNEE`, `JI`.`REPORTER`, `JI`.`CREATED`, `JI`.`UPDATED`, `JI`.`DUEDATE` AS `DUE`, `JI`.`RESOLUTIONDATE` AS `RESOLVED`, `JI`.`DESCRIPTION`, `JI`.`ENVIRONMENT`, `JI`.`ISSUETYPE` AS `TYPE`, `JI`.`PRIORITY`, `JI`.`RESOLUTION`, `JI`.`ISSUESTATUS` AS `STATUS`, `JI`.`SECURITY` AS `SECURITYLEVEL`, `JI`.`VOTES`, `JI`.`WATCHES`, `JI`.`TIMEORIGINALESTIMATE` AS `ORIGINALESTIMATE`, `JI`.`TIMEESTIMATE` AS `ESTIMATE`, `JI`.`TIMESPENT` FROM `INTERNAL`.`JIRAISSUE` AS `JI` WHERE `JI`.`ID` IN (SELECT `EAI`.`ID` FROM `EXPLICIT_ALLOWED_ISSUES` AS `EAI`) OR `JI`.`PROJECT` IN (SELECT `AP`.`ID` FROM `EXPLICIT_ALLOWED_PROJECTS` AS `AP`) {code} which is resolved to {code} LogicalProject(ID=[$0], SUMMARY=[$8], PROJECT=[$3], NUM=[$2], CREATOR=[$6], ASSIGNEE=[$5], REPORTER=[$4], CREATED=[$14], UPDATED=[$15], DUE=[$16], RESOLVED=[$17], DESCRIPTION=[$9], ENVIRONMENT=[$10], TYPE=[$7], PRIORITY=[$11], RESOLUTION=[$12], STATUS=[$13], SECURITYLEVEL=[$24], VOTES=[$18], WATCHES=[$19], ORIGINALESTIMATE=[$20], ESTIMATE=[$21], TIMESPENT=[$22]) LogicalFilter(condition=[OR(true, true)]) LogicalJoin(condition=[=($3, $28)], joinType=[inner]) LogicalJoin(condition=[=($0, $27)], joinType=[inner]) JdbcTableScan(table=[[INTERNAL, JIRAISSUE]]) LogicalAggregate(group=[{0}]) LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_ISSUES]]) LogicalAggregate(group=[{0}]) LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_PROJECTS]]) {code} which is invalid. but when pasting resolved query (not using the declared view ISSUES) explicitly, plan resolves to: {code} LogicalProject(ID=[$0], SUMMARY=[$8], PROJECT=[$3], NUM=[$2], CREATOR=[$6], ASSIGNEE=[$5], REPORTER=[$4], CREATED=[$14], UPDATED=[$15], DUE=[$16], RESOLVED=[$17],
[jira] [Commented] (CALCITE-2009) Possible bug in interpreting ( IN ) OR ( IN ) logic
[ https://issues.apache.org/jira/browse/CALCITE-2009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16313176#comment-16313176 ] Piotr Bojko commented on CALCITE-2009: -- Update. The problem is somewhere at the SqlToRelConverter.convertQuery level. The query {code} select * from ISSUES {code} is resolved to {code} SELECT `JI`.`ID`, `JI`.`SUMMARY`, `JI`.`PROJECT`, `JI`.`ISSUENUM` AS `NUM`, `JI`.`CREATOR`, `JI`.`ASSIGNEE`, `JI`.`REPORTER`, `JI`.`CREATED`, `JI`.`UPDATED`, `JI`.`DUEDATE` AS `DUE`, `JI`.`RESOLUTIONDATE` AS `RESOLVED`, `JI`.`DESCRIPTION`, `JI`.`ENVIRONMENT`, `JI`.`ISSUETYPE` AS `TYPE`, `JI`.`PRIORITY`, `JI`.`RESOLUTION`, `JI`.`ISSUESTATUS` AS `STATUS`, `JI`.`SECURITY` AS `SECURITYLEVEL`, `JI`.`VOTES`, `JI`.`WATCHES`, `JI`.`TIMEORIGINALESTIMATE` AS `ORIGINALESTIMATE`, `JI`.`TIMEESTIMATE` AS `ESTIMATE`, `JI`.`TIMESPENT` FROM `INTERNAL`.`JIRAISSUE` AS `JI` WHERE `JI`.`ID` IN (SELECT `EAI`.`ID` FROM `EXPLICIT_ALLOWED_ISSUES` AS `EAI`) OR `JI`.`PROJECT` IN (SELECT `AP`.`ID` FROM `EXPLICIT_ALLOWED_PROJECTS` AS `AP`) {code} which is resolved to {code} LogicalProject(ID=[$0], SUMMARY=[$8], PROJECT=[$3], NUM=[$2], CREATOR=[$6], ASSIGNEE=[$5], REPORTER=[$4], CREATED=[$14], UPDATED=[$15], DUE=[$16], RESOLVED=[$17], DESCRIPTION=[$9], ENVIRONMENT=[$10], TYPE=[$7], PRIORITY=[$11], RESOLUTION=[$12], STATUS=[$13], SECURITYLEVEL=[$24], VOTES=[$18], WATCHES=[$19], ORIGINALESTIMATE=[$20], ESTIMATE=[$21], TIMESPENT=[$22]) LogicalFilter(condition=[OR(true, true)]) LogicalJoin(condition=[=($3, $28)], joinType=[inner]) LogicalJoin(condition=[=($0, $27)], joinType=[inner]) JdbcTableScan(table=[[INTERNAL, JIRAISSUE]]) LogicalAggregate(group=[{0}]) LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_ISSUES]]) LogicalAggregate(group=[{0}]) LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_PROJECTS]]) {code} which is invalid. but when pasting resolved query (not using the declared view ISSUES) explicitly, plan resolves to: {code} LogicalProject(ID=[$0], SUMMARY=[$8], PROJECT=[$3], NUM=[$2], CREATOR=[$6], ASSIGNEE=[$5], REPORTER=[$4], CREATED=[$14], UPDATED=[$15], DUE=[$16], RESOLVED=[$17], DESCRIPTION=[$9], ENVIRONMENT=[$10], TYPE=[$7], PRIORITY=[$11], RESOLUTION=[$12], STATUS=[$13], SECURITYLEVEL=[$24], VOTES=[$18], WATCHES=[$19], ORIGINALESTIMATE=[$20], ESTIMATE=[$21], TIMESPENT=[$22]) LogicalFilter(condition=[OR(IN($0, {LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_ISSUES]]) }), IN($3, { LogicalProject(ID=[$0]) EnumerableTableScan(table=[[JIRA, EXPLICIT_ALLOWED_PROJECTS]]) }))]) JdbcTableScan(table=[[INTERNAL, JIRAISSUE]]) {code} which is valid. > Possible bug in interpreting ( IN ) OR ( IN ) logic > - > > Key: CALCITE-2009 > URL: https://issues.apache.org/jira/browse/CALCITE-2009 > Project: Calcite > Issue Type: Bug >Affects Versions: 1.14.0, 1.13.0, 1.15.0 >Reporter: Piotr Bojko >Assignee: Julian Hyde > Fix For: 1.16.0 > > Attachments: logs-when-or-is-used.log, logs-when-union-is-used.log > > > I have schema > {code:javascript} > { > "version": "1.0", > "defaultSchema": "JIRA", > "schemas": [ > { > "name": "INTERNAL", > "type": "custom", > "factory": "%%UNDERLYING_SCHEMA_FACTORY", > "operand": {} > }, { > "name": "JIRA", > "type": "custom", > "factory": > "org.apache.calcite.schema.impl.AbstractSchema$Factory", > "operand": {}, > "tables": [ > { > "name": "ISSUES", > "type": "view", > "sql": [ > "SELECT JI.ID, JI.SUMMARY, > JI.PROJECT ", > "FROM INTERNAL.JIRAISSUE as JI > ", > "WHERE JI.ID IN (SELECT EAI.ID > FROM EXPLICIT_ALLOWED_ISSUES AS EAI) ", > "UNION ", > "SELECT JI.ID, JI.SUMMARY, > JI.PROJECT ", > "FROM INTERNAL.JIRAISSUE as JI > ", > "WHERE JI.PROJECT IN (SELECT > AP.ID FROM ALLOWED_PROJECTS AS AP)" > ] > }, > { > "name": "ALLOWED_PROJECTS", >