[jira] [Resolved] (CALCITE-2305) JDBC adapter generates invalid casts on PostgreSQL, because PostgreSQL does not have TINYINT and DOUBLE types

2018-05-11 Thread Julian Hyde (JIRA)

 [ 
https://issues.apache.org/jira/browse/CALCITE-2305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde resolved CALCITE-2305.
--
   Resolution: Fixed
Fix Version/s: 1.17.0

Fixed in 
[4433b102|http://git-wip-us.apache.org/repos/asf/calcite/commit/4433b102]

> JDBC adapter generates invalid casts on PostgreSQL, because PostgreSQL does 
> not have TINYINT and DOUBLE types
> -
>
> Key: CALCITE-2305
> URL: https://issues.apache.org/jira/browse/CALCITE-2305
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Affects Versions: 1.16.0
>Reporter: Chris Baynes
>Assignee: Julian Hyde
>Priority: Major
> Fix For: 1.17.0
>
>
> The types `TINYINT` and `DOUBLE` do not exist in Postgres, so attempting to 
> cast to them throws a runtime exception, e.g.
>  
> {code:java}
> // query
> select CAST("store_id" as TINYINT) from "foodmart"."expense_fact"
> // exception
> java.lang.RuntimeException: exception while executing [select CAST("store_id" 
> as TINYINT) from "foodmart"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.lang.RuntimeException: With materializationsEnabled=false, 
> limit=0
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.sql.SQLException: 
> Error while executing SQL "select CAST("store_id" as TINYINT) from 
> "foodmart"."expense_fact"": while executing SQL [SELECT CAST("store_id" AS 
> TINYINT)
> FROM "public"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.lang.RuntimeException: 
> while executing SQL [SELECT CAST("store_id" AS TINYINT)
> FROM "public"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: org.postgresql.util.PSQLException: 
> ERROR: type "tinyint" does not exist
> Position: 27
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> {code}
>  



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


[jira] [Commented] (CALCITE-2303) Extract for time unit: DECADE not supported!

2018-05-11 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-2303:
--

1 - yes, good catch.

2. I think it makes sense to deal EPOCH in this case, if you have time. I don't 
understand how {{EXTRACT(YEAR FROM TS)}} pertains to EPOCH. Write some test 
cases for 1970-01-01 00:00:00 and 1970-01-01 12:34:56 and 1971-01-01 00:00:00 
and 1969-01-01 00:00:00, when they pass, I think you should be good. 

> Extract for time unit: DECADE not supported!
> 
>
> Key: CALCITE-2303
> URL: https://issues.apache.org/jira/browse/CALCITE-2303
> Project: Calcite
>  Issue Type: Bug
>Reporter: Sergey Nuyanzin
>Assignee: Julian Hyde
>Priority: Major
>
> Here CALCITE-1177 were supported new units
>  however such test
> {code:java}
>   @Test public void testDecadeFunction() throws Exception {
> ExpressionChecker checker = new ExpressionChecker()
> .addExpr("EXTRACT(DECADE FROM ts)", 199L)
> ;
> checker.buildRunAndCheck();
>   }
> {code}
> failed like
>  Extract for time unit: DECADE not supported!
> {noformat}
> SQL:>
> SELECT EXTRACT(DECADE FROM ts) FROM PCOLLECTION
> May 08, 2018 1:34:58 PM 
> org.apache.beam.sdk.extensions.sql.impl.planner.BeamQueryPlanner 
> validateAndConvert
> INFO: SQL:
> SELECT EXTRACT(DECADE FROM `PCOLLECTION`.`ts`)
> FROM `PCOLLECTION` AS `PCOLLECTION`
> May 08, 2018 1:34:58 PM 
> org.apache.beam.sdk.extensions.sql.impl.planner.BeamQueryPlanner 
> convertToBeamRel
> INFO: SQLPlan>
> LogicalProject(EXPR$0=[EXTRACT(FLAG(DECADE), $0)])
>   BeamIOSourceRel(table=[[PCOLLECTION]])
> java.lang.RuntimeException: 
> org.apache.beam.sdk.Pipeline$PipelineExecutionException: 
> java.lang.UnsupportedOperationException: Extract for time unit: DECADE not 
> supported!
>   at 
> org.apache.beam.sdk.extensions.sql.integrationtest.BeamSqlBuiltinFunctionsIntegrationTestBase$ExpressionChecker.buildRunAndCheck(BeamSqlBuiltinFunctionsIntegrationTestBase.java:167)
>   at 
> org.apache.beam.sdk.extensions.sql.integrationtest.BeamSqlDateFunctionsIntegrationTest.testDecadeFunction(BeamSqlDateFunctionsIntegrationTest.java:66)
>   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.apache.beam.sdk.testing.TestPipeline$1.evaluate(TestPipeline.java:317)
>   at org.junit.rules.RunRules.evaluate(RunRules.java:20)
>   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: org.apache.beam.sdk.Pipeline$PipelineExecutionException: 
> java.lang.UnsupportedOperationException: Extract for time unit: DECADE not 
> supported!
>   at 
> org.apache.beam.runners.direct.DirectRunner$DirectPipelineResult.waitUntilFinish(DirectRunner.java:349)
>   at 
> org.apache.beam.runners.direct.DirectRunner$DirectPipelineResult.waitUntilFinish(DirectRunner.java:319)
>   at 
> org.apache.beam.runners.direct.DirectRunner.run(DirectRunner.java:210)
>   at org.apache.beam.runners.direct.DirectRunner.run(DirectRunner.java:66)
>   at 

[jira] [Updated] (CALCITE-2305) JDBC adapter generates invalid casts on PostgreSQL, because PostgreSQL does not have TINYINT and DOUBLE types

2018-05-11 Thread Julian Hyde (JIRA)

 [ 
https://issues.apache.org/jira/browse/CALCITE-2305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-2305:
-
Summary: JDBC adapter generates invalid casts on PostgreSQL, because 
PostgreSQL does not have TINYINT and DOUBLE types  (was: Invalid casting for 
some postgres types)

> JDBC adapter generates invalid casts on PostgreSQL, because PostgreSQL does 
> not have TINYINT and DOUBLE types
> -
>
> Key: CALCITE-2305
> URL: https://issues.apache.org/jira/browse/CALCITE-2305
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Affects Versions: 1.16.0
>Reporter: Chris Baynes
>Assignee: Julian Hyde
>Priority: Major
>
> The types `TINYINT` and `DOUBLE` do not exist in Postgres, so attempting to 
> cast to them throws a runtime exception, e.g.
>  
> {code:java}
> // query
> select CAST("store_id" as TINYINT) from "foodmart"."expense_fact"
> // exception
> java.lang.RuntimeException: exception while executing [select CAST("store_id" 
> as TINYINT) from "foodmart"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.lang.RuntimeException: With materializationsEnabled=false, 
> limit=0
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.sql.SQLException: 
> Error while executing SQL "select CAST("store_id" as TINYINT) from 
> "foodmart"."expense_fact"": while executing SQL [SELECT CAST("store_id" AS 
> TINYINT)
> FROM "public"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.lang.RuntimeException: 
> while executing SQL [SELECT CAST("store_id" AS TINYINT)
> FROM "public"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: org.postgresql.util.PSQLException: 
> ERROR: type "tinyint" does not exist
> Position: 27
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> {code}
>  



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


[jira] [Resolved] (CALCITE-2306) RexLiteral.getValue3 throws AssertionError with null literal of type DECIMAL

2018-05-11 Thread Julian Hyde (JIRA)

 [ 
https://issues.apache.org/jira/browse/CALCITE-2306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde resolved CALCITE-2306.
--
   Resolution: Fixed
Fix Version/s: 1.17.0

Fixed in 
[e1326ace|http://git-wip-us.apache.org/repos/asf/calcite/commit/e1326ace].

> RexLiteral.getValue3 throws AssertionError with null literal of type DECIMAL
> 
>
> Key: CALCITE-2306
> URL: https://issues.apache.org/jira/browse/CALCITE-2306
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.5.0
>Reporter: godfrey he
>Assignee: Julian Hyde
>Priority: Major
> Fix For: 1.17.0
>
>
> {code:java}
> @Test public void testDecimalLiteral() {
>   final RelDataTypeFactory typeFactory =
>   new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
>   RelDataType dateType = typeFactory.createSqlType(SqlTypeName.DECIMAL);
>   final RexBuilder builder = new RexBuilder(typeFactory);
>   RexLiteral literal = builder.makeExactLiteral(null, dateType);
>   assertEquals(null, literal.getValue3());
> }
> {code}
> AssertionError is thrown in above case:
> java.lang.AssertionError
>  at org.apache.calcite.rex.RexLiteral.getValue3(RexLiteral.java:757)
>  at 
> org.apache.calcite.rex.RexBuilderTest.testDecimalLiteral(RexBuilderTest.java:485)



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


[jira] [Updated] (CALCITE-2306) RexLiteral.getValue3 throws AssertionError with null literal of type DECIMAL

2018-05-11 Thread Julian Hyde (JIRA)

 [ 
https://issues.apache.org/jira/browse/CALCITE-2306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-2306:
-
Summary: RexLiteral.getValue3 throws AssertionError with null literal of 
type DECIMAL  (was: throws AssertionError in RexLiteral.getValue3 when null 
value is DECIMAL type)

> RexLiteral.getValue3 throws AssertionError with null literal of type DECIMAL
> 
>
> Key: CALCITE-2306
> URL: https://issues.apache.org/jira/browse/CALCITE-2306
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.5.0
>Reporter: godfrey he
>Assignee: Julian Hyde
>Priority: Major
>
> {code:java}
> @Test public void testDecimalLiteral() {
>   final RelDataTypeFactory typeFactory =
>   new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
>   RelDataType dateType = typeFactory.createSqlType(SqlTypeName.DECIMAL);
>   final RexBuilder builder = new RexBuilder(typeFactory);
>   RexLiteral literal = builder.makeExactLiteral(null, dateType);
>   assertEquals(null, literal.getValue3());
> }
> {code}
> AssertionError is thrown in above case:
> java.lang.AssertionError
>  at org.apache.calcite.rex.RexLiteral.getValue3(RexLiteral.java:757)
>  at 
> org.apache.calcite.rex.RexBuilderTest.testDecimalLiteral(RexBuilderTest.java:485)



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


[jira] [Commented] (CALCITE-2305) Invalid casting for some postgres types

2018-05-11 Thread Chris Baynes (JIRA)

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

Chris Baynes commented on CALCITE-2305:
---

That's a fair point, I've added some comments.

> Invalid casting for some postgres types
> ---
>
> Key: CALCITE-2305
> URL: https://issues.apache.org/jira/browse/CALCITE-2305
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Affects Versions: 1.16.0
>Reporter: Chris Baynes
>Assignee: Julian Hyde
>Priority: Major
>
> The types `TINYINT` and `DOUBLE` do not exist in Postgres, so attempting to 
> cast to them throws a runtime exception, e.g.
>  
> {code:java}
> // query
> select CAST("store_id" as TINYINT) from "foodmart"."expense_fact"
> // exception
> java.lang.RuntimeException: exception while executing [select CAST("store_id" 
> as TINYINT) from "foodmart"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.lang.RuntimeException: With materializationsEnabled=false, 
> limit=0
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.sql.SQLException: 
> Error while executing SQL "select CAST("store_id" as TINYINT) from 
> "foodmart"."expense_fact"": while executing SQL [SELECT CAST("store_id" AS 
> TINYINT)
> FROM "public"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.lang.RuntimeException: 
> while executing SQL [SELECT CAST("store_id" AS TINYINT)
> FROM "public"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: org.postgresql.util.PSQLException: 
> ERROR: type "tinyint" does not exist
> Position: 27
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> {code}
>  



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


[jira] [Commented] (CALCITE-2247) Add rule to push in condition condition into a related disjunctive expression

2018-05-11 Thread Zoltan Haindrich (JIRA)

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

Zoltan Haindrich commented on CALCITE-2247:
---

I've checked it separetly; it was there before my changeset - so I think it 
would be better to fix that separetly; however I've added a testcase which is 
Ignored right now

> Add rule to push in condition condition into a related disjunctive expression
> -
>
> Key: CALCITE-2247
> URL: https://issues.apache.org/jira/browse/CALCITE-2247
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Zoltan Haindrich
>Assignee: Zoltan Haindrich
>Priority: Major
>
> Simplify expressions like: {code}a = 1 AND (a = 1 OR a = 2){code} to {code}a 
> = 1{code}
> Conditions to apply will be:
> * in an AND condition there exists a comparison(c) and an OR (o)
> * o and c only reference 1 variable
> See HIVE-19097 for more info.



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


[jira] [Commented] (CALCITE-2305) Invalid casting for some postgres types

2018-05-11 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-2305:
--

Change looks OK, but it would be good if some of the rationale in this bug made 
it into the code. If I were maintaining the code you just wrote I would be 
mystified.

> Invalid casting for some postgres types
> ---
>
> Key: CALCITE-2305
> URL: https://issues.apache.org/jira/browse/CALCITE-2305
> Project: Calcite
>  Issue Type: Bug
>  Components: jdbc-adapter
>Affects Versions: 1.16.0
>Reporter: Chris Baynes
>Assignee: Julian Hyde
>Priority: Major
>
> The types `TINYINT` and `DOUBLE` do not exist in Postgres, so attempting to 
> cast to them throws a runtime exception, e.g.
>  
> {code:java}
> // query
> select CAST("store_id" as TINYINT) from "foodmart"."expense_fact"
> // exception
> java.lang.RuntimeException: exception while executing [select CAST("store_id" 
> as TINYINT) from "foodmart"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.lang.RuntimeException: With materializationsEnabled=false, 
> limit=0
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.sql.SQLException: 
> Error while executing SQL "select CAST("store_id" as TINYINT) from 
> "foodmart"."expense_fact"": while executing SQL [SELECT CAST("store_id" AS 
> TINYINT)
> FROM "public"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: java.lang.RuntimeException: 
> while executing SQL [SELECT CAST("store_id" AS TINYINT)
> FROM "public"."expense_fact"]
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> Caused by: org.postgresql.util.PSQLException: 
> ERROR: type "tinyint" does not exist
> Position: 27
> at org.apache.calcite.test.JdbcAdapterTest.testCast(JdbcAdapterTest.java:478)
> {code}
>  



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


[jira] [Commented] (CALCITE-2295) Correlated SubQuery with Project will generate error plan

2018-05-11 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-2295:
--

The more modern way to handle sub-queries and decorrelation is using planner 
rules. SqlToRelConverter is capable of handling these but there are bugs that 
we don't intend to fix.

> Correlated SubQuery with Project will generate error plan
> -
>
> Key: CALCITE-2295
> URL: https://issues.apache.org/jira/browse/CALCITE-2295
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.15.0
>Reporter: godfrey he
>Assignee: Julian Hyde
>Priority: Critical
>
> test case in *RelOptRulesTest.java*:
> {code:java}
> @Test public void testDecorrelateWithProject() throws Exception {
> final String sql = "select sal,\n"
>+ "exists (select * from emp_b where emp.deptno = 
> emp_b.deptno)\n"
>+ "from sales.emp";
> checkSubQuery(sql).withLateDecorrelation(true).check();
> }
> {code}
> after *SqlToRelConverter*, the plan is
> {code:java}
> LogicalProject(SAL=[$5], EXPR$1=[EXISTS({
> LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
>   LogicalTableScan(table=[[CATALOG, SALES, EMP_B]])
> })])
>   LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> NOTES: *LogicalProject* does not have any *_variablesSet_* attributes.
> the correct plan should be:
> {code:java}
> LogicalProject(SAL=[$5], EXPR$1=[EXISTS({
> LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
>   LogicalTableScan(table=[[CATALOG, SALES, EMP_B]])
> })], variablesSet=[[$cor0]])
>   LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}



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


[jira] [Commented] (CALCITE-2247) Add rule to push in condition condition into a related disjunctive expression

2018-05-11 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-2247:
--

Did the problem with {{x AND NOT x}} exist before your change? If you didn't 
make things any worse we can accept your change.

> Add rule to push in condition condition into a related disjunctive expression
> -
>
> Key: CALCITE-2247
> URL: https://issues.apache.org/jira/browse/CALCITE-2247
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Zoltan Haindrich
>Assignee: Zoltan Haindrich
>Priority: Major
>
> Simplify expressions like: {code}a = 1 AND (a = 1 OR a = 2){code} to {code}a 
> = 1{code}
> Conditions to apply will be:
> * in an AND condition there exists a comparison(c) and an OR (o)
> * o and c only reference 1 variable
> See HIVE-19097 for more info.



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


[jira] [Commented] (CALCITE-2306) throws AssertionError in RexLiteral.getValue3 when null value is DECIMAL type

2018-05-11 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-2306:
--

Reviewing now.

> throws AssertionError in RexLiteral.getValue3 when null value is DECIMAL type
> -
>
> Key: CALCITE-2306
> URL: https://issues.apache.org/jira/browse/CALCITE-2306
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.5.0
>Reporter: godfrey he
>Assignee: Julian Hyde
>Priority: Major
>
> {code:java}
> @Test public void testDecimalLiteral() {
>   final RelDataTypeFactory typeFactory =
>   new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
>   RelDataType dateType = typeFactory.createSqlType(SqlTypeName.DECIMAL);
>   final RexBuilder builder = new RexBuilder(typeFactory);
>   RexLiteral literal = builder.makeExactLiteral(null, dateType);
>   assertEquals(null, literal.getValue3());
> }
> {code}
> AssertionError is thrown in above case:
> java.lang.AssertionError
>  at org.apache.calcite.rex.RexLiteral.getValue3(RexLiteral.java:757)
>  at 
> org.apache.calcite.rex.RexBuilderTest.testDecimalLiteral(RexBuilderTest.java:485)



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


[jira] [Updated] (CALCITE-2308) Query with COUNT(DISTINCT) ... GROUP BY CUBE gives wrong result

2018-05-11 Thread Julian Hyde (JIRA)

 [ 
https://issues.apache.org/jira/browse/CALCITE-2308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-2308:
-
Description: 
Query with COUNT(DISTINCT) ... GROUP BY CUBE gives wrong result. The following 
query (and wrong result) is in {{agg.iq}}:
{code:java}
select count(distinct deptno) as cd, count(*) as c
from "scott".emp
group by cube(deptno);
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 3 |
++---+
(4 rows){code}
the correct reusst is: 
{code:java}
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 14 |
++---+
{code}
 

  was:
 

test in agg.iq:
{code:java}
select count(distinct deptno) as cd, count(*) as c
from "scott".emp
group by cube(deptno);
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 3 |
++---+
(4 rows){code}
the correct reuslt is: 
{code:java}
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 14 |
++---+
{code}
 

 


> Query with COUNT(DISTINCT) ... GROUP BY CUBE gives wrong result
> ---
>
> Key: CALCITE-2308
> URL: https://issues.apache.org/jira/browse/CALCITE-2308
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.15.0
>Reporter: godfrey he
>Assignee: Julian Hyde
>Priority: Major
>
> Query with COUNT(DISTINCT) ... GROUP BY CUBE gives wrong result. The 
> following query (and wrong result) is in {{agg.iq}}:
> {code:java}
> select count(distinct deptno) as cd, count(*) as c
> from "scott".emp
> group by cube(deptno);
> ++---+
> | CD | C |
> ++---+
> |  1 | 3 |
> |  1 | 5 |
> |  1 | 6 |
> |  3 | 3 |
> ++---+
> (4 rows){code}
> the correct reusst is: 
> {code:java}
> ++---+
> | CD | C |
> ++---+
> |  1 | 3 |
> |  1 | 5 |
> |  1 | 6 |
> |  3 | 14 |
> ++---+
> {code}
>  



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


[jira] [Updated] (CALCITE-2308) Query with COUNT(DISTINCT) ... GROUP BY CUBE gives wrong result

2018-05-11 Thread Julian Hyde (JIRA)

 [ 
https://issues.apache.org/jira/browse/CALCITE-2308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-2308:
-
Summary: Query with COUNT(DISTINCT) ... GROUP BY CUBE gives wrong result  
(was: error reuslt in agg.iq when argument to COUNT(DISTINCT) is a GROUP BY 
column)

> Query with COUNT(DISTINCT) ... GROUP BY CUBE gives wrong result
> ---
>
> Key: CALCITE-2308
> URL: https://issues.apache.org/jira/browse/CALCITE-2308
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.15.0
>Reporter: godfrey he
>Assignee: Julian Hyde
>Priority: Major
>
>  
> test in agg.iq:
> {code:java}
> select count(distinct deptno) as cd, count(*) as c
> from "scott".emp
> group by cube(deptno);
> ++---+
> | CD | C |
> ++---+
> |  1 | 3 |
> |  1 | 5 |
> |  1 | 6 |
> |  3 | 3 |
> ++---+
> (4 rows){code}
> the correct reuslt is: 
> {code:java}
> ++---+
> | CD | C |
> ++---+
> |  1 | 3 |
> |  1 | 5 |
> |  1 | 6 |
> |  3 | 14 |
> ++---+
> {code}
>  
>  



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


[jira] [Updated] (CALCITE-2308) error reuslt in agg.iq when argument to COUNT(DISTINCT) is a GROUP BY column

2018-05-11 Thread godfrey he (JIRA)

 [ 
https://issues.apache.org/jira/browse/CALCITE-2308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

godfrey he updated CALCITE-2308:

Summary: error reuslt in agg.iq when argument to COUNT(DISTINCT) is a GROUP 
BY column  (was: error sql reuslt in agg.iq when argument to COUNT(DISTINCT) is 
a GROUP BY column)

> error reuslt in agg.iq when argument to COUNT(DISTINCT) is a GROUP BY column
> 
>
> Key: CALCITE-2308
> URL: https://issues.apache.org/jira/browse/CALCITE-2308
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.15.0
>Reporter: godfrey he
>Assignee: Julian Hyde
>Priority: Major
>
>  
> test in agg.iq:
> {code:java}
> select count(distinct deptno) as cd, count(*) as c
> from "scott".emp
> group by cube(deptno);
> ++---+
> | CD | C |
> ++---+
> |  1 | 3 |
> |  1 | 5 |
> |  1 | 6 |
> |  3 | 3 |
> ++---+
> (4 rows){code}
> the correct reuslt is:
>  
>  
> {code:java}
> ++---+
> | CD | C |
> ++---+
> |  1 | 3 |
> |  1 | 5 |
> |  1 | 6 |
> |  3 | 14 |
> ++---+
> {code}
>  
>  



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


[jira] [Updated] (CALCITE-2308) error reuslt in agg.iq when argument to COUNT(DISTINCT) is a GROUP BY column

2018-05-11 Thread godfrey he (JIRA)

 [ 
https://issues.apache.org/jira/browse/CALCITE-2308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

godfrey he updated CALCITE-2308:

Description: 
 

test in agg.iq:
{code:java}
select count(distinct deptno) as cd, count(*) as c
from "scott".emp
group by cube(deptno);
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 3 |
++---+
(4 rows){code}
the correct reuslt is: 
{code:java}
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 14 |
++---+
{code}
 

 

  was:
 

test in agg.iq:
{code:java}
select count(distinct deptno) as cd, count(*) as c
from "scott".emp
group by cube(deptno);
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 3 |
++---+
(4 rows){code}
the correct reuslt is:

 

 
{code:java}
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 14 |
++---+
{code}
 

 


> error reuslt in agg.iq when argument to COUNT(DISTINCT) is a GROUP BY column
> 
>
> Key: CALCITE-2308
> URL: https://issues.apache.org/jira/browse/CALCITE-2308
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.15.0
>Reporter: godfrey he
>Assignee: Julian Hyde
>Priority: Major
>
>  
> test in agg.iq:
> {code:java}
> select count(distinct deptno) as cd, count(*) as c
> from "scott".emp
> group by cube(deptno);
> ++---+
> | CD | C |
> ++---+
> |  1 | 3 |
> |  1 | 5 |
> |  1 | 6 |
> |  3 | 3 |
> ++---+
> (4 rows){code}
> the correct reuslt is: 
> {code:java}
> ++---+
> | CD | C |
> ++---+
> |  1 | 3 |
> |  1 | 5 |
> |  1 | 6 |
> |  3 | 14 |
> ++---+
> {code}
>  
>  



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


[jira] [Created] (CALCITE-2308) error sql reuslt in agg.iq when argument to COUNT(DISTINCT) is a GROUP BY column

2018-05-11 Thread godfrey he (JIRA)
godfrey he created CALCITE-2308:
---

 Summary: error sql reuslt in agg.iq when argument to 
COUNT(DISTINCT) is a GROUP BY column
 Key: CALCITE-2308
 URL: https://issues.apache.org/jira/browse/CALCITE-2308
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.15.0
Reporter: godfrey he
Assignee: Julian Hyde


 

test in agg.iq:
{code:java}
select count(distinct deptno) as cd, count(*) as c
from "scott".emp
group by cube(deptno);
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 3 |
++---+
(4 rows){code}
the correct reuslt is:

 

 
{code:java}
++---+
| CD | C |
++---+
|  1 | 3 |
|  1 | 5 |
|  1 | 6 |
|  3 | 14 |
++---+
{code}
 

 



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