[jira] [Created] (CALCITE-3315) Multiple failures in Druid IT tests due to implicit casts

2019-08-30 Thread Stamatis Zampetakis (Jira)
Stamatis Zampetakis created CALCITE-3315:


 Summary: Multiple failures in Druid IT tests due to implicit casts 
 Key: CALCITE-3315
 URL: https://issues.apache.org/jira/browse/CALCITE-3315
 Project: Calcite
  Issue Type: Bug
Reporter: Stamatis Zampetakis
 Fix For: 1.21.0


After merging CALCITE-2302 there are 12 test failures in DruidAdapterIT and 
DruidAdapter2IT.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)


Calcite-Master - Build # 1325 - Failure

2019-08-30 Thread Apache Jenkins Server
The Apache Jenkins build system has built Calcite-Master (build #1325)

Status: Failure

Check console output at https://builds.apache.org/job/Calcite-Master/1325/ to 
view the results.

[jira] [Created] (CALCITE-3314) CVSS dependency-check-maven fails for calcite-pig, calcite-piglet, calcite-spark

2019-08-30 Thread Stamatis Zampetakis (Jira)
Stamatis Zampetakis created CALCITE-3314:


 Summary: CVSS dependency-check-maven fails for calcite-pig, 
calcite-piglet, calcite-spark
 Key: CALCITE-3314
 URL: https://issues.apache.org/jira/browse/CALCITE-3314
 Project: Calcite
  Issue Type: Bug
Reporter: Stamatis Zampetakis
Assignee: Stamatis Zampetakis
 Fix For: 1.21.0


Calcite build fails if the CVSS dependency check is active since there are 
serious vulnerabilties in calcite-pig, calcite-piglet, calcite-spark. 

Running mvn install -Ppedantic -fn gives the following errors:

{noformat}
ERROR] Failed to execute goal org.owasp:dependency-check-maven:5.2.1:check 
(default) on project calcite-pig: 
[ERROR] 
[ERROR] One or more dependencies were identified with vulnerabilities that have 
a CVSS score greater than or equal to '8.0': 
[ERROR] 
[ERROR] jetty-6.1.26.jar: CVE-2017-7658, CVE-2017-7657
[ERROR] groovy-all-1.8.6.jar: CVE-2015-3253, CVE-2016-6814

[ERROR] Failed to execute goal org.owasp:dependency-check-maven:5.2.1:check 
(default) on project calcite-piglet: 
[ERROR] 
[ERROR] One or more dependencies were identified with vulnerabilities that have 
a CVSS score greater than or equal to '8.0': 
[ERROR] 
[ERROR] jetty-6.1.26.jar: CVE-2017-7658, CVE-2017-7657
[ERROR] jackson-core-asl-1.8.8.jar: CVE-2017-17485, CVE-2017-7525, 
CVE-2017-15095
[ERROR] groovy-all-1.8.6.jar: CVE-2015-3253, CVE-2016-6814
[ERROR] jackson-xc-1.8.3.jar: CVE-2017-17485, CVE-2017-7525, CVE-2017-15095
[ERROR] hadoop-auth-2.7.5.jar: CVE-2018-8029, CVE-2018-11766, CVE-2018-8009
[ERROR] api-util-1.0.0-M20.jar: CVE-2018-1337
[ERROR] zookeeper-3.4.6.jar: CVE-2016-5017
[ERROR] 
htrace-core-3.1.0-incubating.jar/META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml:
 CVE-2017-17485, CVE-2018-5968, CVE-2017-15095, CVE-2019-14379, CVE-2018-19362, 
CVE-2018-19361, CVE-2018-19360, CVE-2017-7525, CVE-2018-11307, CVE-2018-14718, 
CVE-2018-7489, CVE-2018-14719, CVE-2018-14721, CVE-2018-14720

[ERROR] Failed to execute goal org.owasp:dependency-check-maven:5.2.1:check 
(default) on project calcite-spark: 
[ERROR] 
[ERROR] One or more dependencies were identified with vulnerabilities that have 
a CVSS score greater than or equal to '8.0': 
[ERROR] 
[ERROR] spark-core_2.10-2.2.0.jar: CVE-2018-17190
[ERROR] api-util-1.0.0-M20.jar: CVE-2018-1337
[ERROR] hadoop-mapreduce-client-core-2.7.5.jar: CVE-2018-8029, CVE-2018-11766, 
CVE-2018-8009
[ERROR] bcprov-jdk15on-1.51.jar: CVE-2018-1000613
[ERROR] zookeeper-3.4.6.jar: CVE-2016-5017
[ERROR] unused-1.0.0.jar: CVE-2018-17190
[ERROR] 
htrace-core-3.1.0-incubating.jar/META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml:
 CVE-2017-17485, CVE-2018-5968, CVE-2017-15095, CVE-2019-14379, CVE-2018-19362, 
CVE-2018-19361, CVE-2018-19360, CVE-2017-7525, CVE-2018-11307, CVE-2018-14718, 
CVE-2018-7489, CVE-2018-14719, CVE-2018-14721, CVE-2018-14720
[ERROR] 
spark-core_2.10-2.2.0.jar/META-INF/maven/org.eclipse.jetty/jetty-plus/pom.xml: 
CVE-2017-7658, CVE-2017-7657

{noformat}
 



--
This message was sent by Atlassian Jira
(v8.3.2#803003)


Expected conversion for TIMESTAMPDIFF

2019-08-30 Thread Pavel Gubin
Trying to understand expected conversion to SQL for TIMESTAMPDIFF function. 
According to this bug: 
https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-3312 
 it is 
converted to something like: 
CAST(/INT(Reinterpret(-(2017-01-01 00:00:00, 2016-01-01 00:00:00)), 
12)):INTEGER NOT NULL
which seems incorrect and missing some info for many databases. 

For example, PostgreSQL returns interval in days here:

select TIMESTAMP '2017-01-01 00:00:00' - TIMESTAMP '2016-01-01 00:00:00';
 ?column? 
--
 366 days
(1 row)

How Reinterpret supposed to be converted for PostgreSQL given that it doesn't 
contain output type and what's with division by 12?

Willing to fix this, could somebody give an insight?

Thanks,
Pavel




[jira] [Created] (CALCITE-3313) AssertionError for an invalid type when using REGEXP_REPLACE

2019-08-30 Thread Wang Yanlin (Jira)
Wang Yanlin created CALCITE-3313:


 Summary: AssertionError for an invalid type when using 
REGEXP_REPLACE
 Key: CALCITE-3313
 URL: https://issues.apache.org/jira/browse/CALCITE-3313
 Project: Calcite
  Issue Type: Bug
Reporter: Wang Yanlin


When using REGEXP_REPLACE function with an invalid type parameter, like this

{code:sql}
select regexp_replace(12, 'b', 'X', 1, 3, 'i')
{code}

 we got
{code:java}
java.lang.AssertionError: If you see this, assign operandTypeChecker a value or 
override this function
at 
org.apache.calcite.sql.SqlOperator.getAllowedSignatures(SqlOperator.java:730)
at 
org.apache.calcite.sql.SqlOperator.getAllowedSignatures(SqlOperator.java:721)
at 
org.apache.calcite.sql.SqlCallBinding.newValidationSignatureError(SqlCallBinding.java:283)
at 
org.apache.calcite.sql.type.FamilyOperandTypeChecker.checkSingleOperandType(FamilyOperandTypeChecker.java:96)
at 
org.apache.calcite.sql.fun.SqlRegexpReplaceFunction.checkOperandTypes(SqlRegexpReplaceFunction.java:56)
at 
org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:432)
at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:298)
at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:216)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5626)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5613)
at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1688)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1673)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:476)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4104)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3392)
at 
org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1005)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:965)
at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
{code}

Better to give a more detailed message of the allowed signatures.




--
This message was sent by Atlassian Jira
(v8.3.2#803003)


[jira] [Created] (CALCITE-3312) TIMESTAMPDIFF cannot be converted to SQL

2019-08-30 Thread Pavel Gubin (Jira)
Pavel Gubin created CALCITE-3312:


 Summary: TIMESTAMPDIFF cannot be converted to SQL
 Key: CALCITE-3312
 URL: https://issues.apache.org/jira/browse/CALCITE-3312
 Project: Calcite
  Issue Type: Bug
  Components: core
Reporter: Pavel Gubin


The following test in {{RelToSqlConverterTest}}:
{code}
  @Test public void testTimestampDiff() {
String query = "SELECT {fn TIMESTAMPDIFF(SQL_TSI_YEAR,TIMESTAMP '2016-01-01 
00:00:00', TIMESTAMP '2017-01-01 00:00:00')}";
String expected = "";
sql(query).ok(expected);
  }
{code}

fails with:
{noformat}
java.lang.UnsupportedOperationException: class 
org.apache.calcite.sql.SqlSyntax$6: SPECIAL

at org.apache.calcite.util.Util.needToImplement(Util.java:967)
at org.apache.calcite.sql.SqlSyntax$6.unparse(SqlSyntax.java:116)
at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:348)
at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:402)
at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:105)
at org.apache.calcite.sql.SqlUtil.unparseBinarySyntax(SqlUtil.java:382)
at org.apache.calcite.sql.SqlSyntax$3.unparse(SqlSyntax.java:65)
at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:348)
at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:402)
at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:108)
at 
org.apache.calcite.sql.fun.SqlCastFunction.unparse(SqlCastFunction.java:174)
at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:402)
at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:108)
at org.apache.calcite.sql.SqlNodeList.commaList(SqlNodeList.java:121)
at 
org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:365)
at 
org.apache.calcite.sql.SqlOperator.unparseListClause(SqlOperator.java:354)
at 
org.apache.calcite.sql.SqlSelectOperator.unparse(SqlSelectOperator.java:152)
at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:402)
at org.apache.calcite.sql.SqlSelect.unparse(SqlSelect.java:230)
at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:152)
at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:157)
at 
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.toSql(RelToSqlConverterTest.java:145)
at 
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.access$100(RelToSqlConverterTest.java:77)
at 
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.exec(RelToSqlConverterTest.java:3634)
at 
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.ok(RelToSqlConverterTest.java:3609)
at 
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.testTimestampDiff(RelToSqlConverterTest.java:1942)
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)
{noformat}



--
This message was sent by Atlassian Jira
(v8.3.2#803003)


[jira] [Created] (CALCITE-3311) Add doc to site for implicit type coercion

2019-08-30 Thread Danny Chan (Jira)
Danny Chan created CALCITE-3311:
---

 Summary: Add doc to site for implicit type coercion
 Key: CALCITE-3311
 URL: https://issues.apache.org/jira/browse/CALCITE-3311
 Project: Calcite
  Issue Type: Sub-task
  Components: site
Affects Versions: 1.20.0
Reporter: Danny Chan
Assignee: Danny Chan
 Fix For: 1.21.0






--
This message was sent by Atlassian Jira
(v8.3.2#803003)


[jira] [Created] (CALCITE-3310) Approximate and exact aggregate calls are recognized as the same during sql-to-rel conversion

2019-08-30 Thread Danny Chan (Jira)
Danny Chan created CALCITE-3310:
---

 Summary: Approximate and exact aggregate calls are recognized as 
the same during sql-to-rel conversion
 Key: CALCITE-3310
 URL: https://issues.apache.org/jira/browse/CALCITE-3310
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.20.0
Reporter: Danny Chan
Assignee: Danny Chan
 Fix For: 1.21.0


For sql:
{code:sql}
SELECT empno, count(distinct ename)
approx_count_distinct(ename)
FROM emp
GROUP BY empno
{code}
After sql-to-rel conversion, the plan is:
{code:sql}
LogicalProject(EMPNO=[$0], EXPR$1=[$1], EXPR$2=[$1])
  LogicalAggregate(group=[{0}], EXPR$1=[COUNT(DISTINCT $1)])
LogicalProject(EMPNO=[$0], ENAME=[$1])
  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
{code}




--
This message was sent by Atlassian Jira
(v8.3.2#803003)


[jira] [Created] (CALCITE-3309) Refactor generatePredicate method from EnumerableNestedLoopJoin/EnumerableHashJoin/EnumerableBatchNestedLoopJoin into a single location

2019-08-30 Thread Ruben Quesada Lopez (Jira)
Ruben Quesada Lopez created CALCITE-3309:


 Summary: Refactor generatePredicate method from 
EnumerableNestedLoopJoin/EnumerableHashJoin/EnumerableBatchNestedLoopJoin into 
a single location
 Key: CALCITE-3309
 URL: https://issues.apache.org/jira/browse/CALCITE-3309
 Project: Calcite
  Issue Type: Improvement
Reporter: Ruben Quesada Lopez
Assignee: Ruben Quesada Lopez
 Fix For: 1.21.0


The method {{EnumerableNestedLoopJoin#predicate}} (that generates a Predicate 
Expression based on a RexNode condition) has been copied pasted as 
{{EnumerableBatchNestedLoopJoin#generatePredicate}} due to CALCITE-2979, and 
{{EnumerableHashJoin#generatePredicate}} due to CALCITE-2973.
The goal of this ticket is to refactor that method into a single location (e.g. 
EnumUtils) where it can be accessible by all 3 Enumerable Joins.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)