[jira] [Commented] (CALCITE-110) utf-16 is wrong in SqlUtil.translateCharacterSetName()
[ https://issues.apache.org/jira/browse/CALCITE-110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16348105#comment-16348105 ] Ye Ding commented on CALCITE-110: - I have ran into same trouble, after exploring the source code I found a suspicious code that may cause the problem. Here is a code block from *RexBuilder*, between L869 and L883. {code:java} case CHAR: // Character literals must have a charset and collation. Populate // from the type if necessary. assert o instanceof NlsString; NlsString nlsString = (NlsString) o; if ((nlsString.getCollation() == null) || (nlsString.getCharset() == null)) { assert type.getSqlTypeName() == SqlTypeName.CHAR; assert type.getCharset().name() != null; assert type.getCollation() != null; o = new NlsString( nlsString.getValue(), type.getCharset().name(), type.getCollation()); } {code} At the last line, a *Java* charset name is used to construct NlsString. But from the code of NlsString's constructor, the charsetName is supposed to be *SQL* charset name. {code:java} public NlsString( String value, String charsetName, SqlCollation collation) { assert value != null; if (null != charsetName) { charsetName = charsetName.toUpperCase(Locale.ROOT); this.charsetName = charsetName; String javaCharsetName = SqlUtil.translateCharacterSetName(charsetName); if (javaCharsetName == null) { throw new UnsupportedCharsetException(charsetName); } this.charset = Charset.forName(javaCharsetName); CharsetEncoder encoder = charset.newEncoder(); {code} I have not read and fully understood codes, so I'm not sure if it's the root cause of OP's (and mine) problem. Currently I've managed to work around it by setting "saffron.default.charset" to "UTF-16LE". > utf-16 is wrong in SqlUtil.translateCharacterSetName() > --- > > Key: CALCITE-110 > URL: https://issues.apache.org/jira/browse/CALCITE-110 > Project: Calcite > Issue Type: Bug >Reporter: GitHub Import >Priority: Major > Labels: github-import > > SqlUtil.translateCharacterSetName() should compare "UTF-16" instaed of > "UTF16". > Now it will trigger the exception if I change the "saffron.default.charset" > system property to "UTF-16". > java.nio.charset.UnsupportedCharsetException: UTF-16 > at org.eigenbase.util.NlsString.(NlsString.java:77) > at org.eigenbase.rex.RexBuilder.makeLiteral(RexBuilder.java:824) > at org.eigenbase.rex.RexBuilder.(RexBuilder.java:84) > at > net.hydromatic.optiq.prepare.OptiqPrepareImpl$OptiqPreparingStmt.(OptiqPrepareImpl.java:519) > at > net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare2_(OptiqPrepareImpl.java:275) > at > net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare_(OptiqPrepareImpl.java:223) > at > net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepareSql(OptiqPrepareImpl.java:193) > at > net.hydromatic.optiq.jdbc.OptiqConnectionImpl.parseQuery(OptiqConnectionImpl.java:155) > at net.hydromatic.optiq.jdbc.MetaImpl.prepare(MetaImpl.java:696) > at > net.hydromatic.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:68) > Imported from GitHub > Url: https://github.com/julianhyde/optiq/issues/110 > Created by: [jiangxuchina|https://github.com/jiangxuchina] > Labels: > Created at: Wed Jan 08 04:59:19 CET 2014 > State: closed -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2053) Overloaded user-defined functions that have Double and BigDecimal arguments will goes wrong
[ https://issues.apache.org/jira/browse/CALCITE-2053?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16348015#comment-16348015 ] yuqi commented on CALCITE-2053: --- [~julianhyde] , I confirm this, here is my MR [https://github.com/apache/calcite/pull/619] , please help to review this PR if you have time, thanks > Overloaded user-defined functions that have Double and BigDecimal arguments > will goes wrong > --- > > Key: CALCITE-2053 > URL: https://issues.apache.org/jira/browse/CALCITE-2053 > Project: Calcite > Issue Type: Bug > Components: core >Affects Versions: 1.13.0 >Reporter: yuqi >Assignee: Julian Hyde >Priority: Major > > We add the following udf method in Smalls.AllTypesFunction > {code:java} >public double toDouble(BigDecimal var) { > return var.doubleValue(); >} >public double toDouble(Double var) { > return var; > } > > {code} > when test it : > {code:java} > @Test > public void testBigDecimalAndLong() { > final CalciteAssert.AssertThat with = withUdf(); > with.query("values \"adhoc\".\"toDouble\"(cast(1.0 as double))") > .returns("EXPR$0=1.0\n"); > }{code} > where price is a double value in table tb, exception occurs: > {code:java} > java.lang.AssertionError: DECIMAL(19, 0) at > org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:154) > at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:626) at > org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:592) > at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:446) at > org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at > org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at > org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at > org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5432) > at > org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5419) > at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at > org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1606) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1591) > at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:236) at > org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:5136) > at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:115) at > org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:235) at > org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:5136) > at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:115) at > org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:903) > at > org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:613) > at > org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:553) > at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:264) at > org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:230) at > org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:781) > at > org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:640) > at > org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:610) > at > org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:221) > at > org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603) > at > org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638) > at > org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149) > at > org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) > at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:568) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1346) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1329) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1293) > at org.apache.calcite.test.UdfTest.testBigDecimalAndLong(UdfTest.java:891) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at >
[jira] [Updated] (CALCITE-2053) Overloaded user-defined functions that have Double and BigDecimal arguments will goes wrong
[ https://issues.apache.org/jira/browse/CALCITE-2053?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] yuqi updated CALCITE-2053: -- Description: We add the following udf method in Smalls.AllTypesFunction {code:java} public double toDouble(BigDecimal var) { return var.doubleValue(); } public double toDouble(Double var) { return var; } {code} when test it : {code:java} @Test public void testBigDecimalAndLong() { final CalciteAssert.AssertThat with = withUdf(); with.query("values \"adhoc\".\"toDouble\"(cast(1.0 as double))") .returns("EXPR$0=1.0\n"); }{code} where price is a double value in table tb, exception occurs: {code:java} java.lang.AssertionError: DECIMAL(19, 0) at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:154) at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:626) at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:592) at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:446) at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5432) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5419) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1606) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1591) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:236) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:5136) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:115) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:235) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:5136) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:115) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:903) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:613) at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:553) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:264) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:230) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:781) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:640) at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:610) at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:221) at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603) at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:568) at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1346) at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1329) at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1293) at org.apache.calcite.test.UdfTest.testBigDecimalAndLong(UdfTest.java:891) 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:497) 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
[jira] [Updated] (CALCITE-2053) Overloaded user-defined functions that have Double and BigDecimal arguments will goes wrong
[ https://issues.apache.org/jira/browse/CALCITE-2053?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] yuqi updated CALCITE-2053: -- Description: We add the following udf method in Smalls.AllTypesFunction {code:java} public double toDouble(BigDecimal var) { return var.doubleValue(); } public double toDouble(Double var) { return var; } {code} when test it : {code:java} @Test public void testBigDecimalAndLong() { final CalciteAssert.AssertThat with = withUdf(); with.query("values \"adhoc\".\"toDouble\"(cast(1.0 as double))") .returns("EXPR$0=1.0\n"); }{code} where price is a double value in table tb, exception occurs: {code:java} java.lang.AssertionError at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:153) at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:627) at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:593) at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:447) at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5053) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5040) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1588) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1573) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:225) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:4764) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:114) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:224) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:4764) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:114) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:895) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:605) at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:550) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:264) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:228) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:784) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:639) at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:609) at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:214) at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603) at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) java.lang.AssertionError: DECIMAL(19, 0) at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:154) at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:626) at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:592) at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:446) at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5432) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5419) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1606) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1591) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:236) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:5136) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:115) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:235) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at
[jira] [Updated] (CALCITE-2053) Overloaded user-defined functions that have Double and BigDecimal arguments will goes wrong
[ https://issues.apache.org/jira/browse/CALCITE-2053?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] yuqi updated CALCITE-2053: -- Description: We add the following udf method in Smalls.AllTypesFunction {code:java} public double toDouble(BigDecimal var) { return var.doubleValue(); } public double toDouble(Double var) { return var; } {code} when test it : {code:java} @Test public void testBigDecimalAndLong() { final CalciteAssert.AssertThat with = withUdf(); with.query("values \"adhoc\".\"toDouble\"(cast(1.0 as double))") .returns("EXPR$0=1.0\n"); }{code} where price is a double value in table tb, exception occurs: {code:java} java.lang.AssertionError at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:153) at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:627) at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:593) at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:447) at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5053) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5040) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1588) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1573) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:225) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:4764) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:114) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:224) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:4764) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:114) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:895) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:605) at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:550) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:264) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:228) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:784) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:639) at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:609) at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:214) at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603) at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) {code} was: We add the following udf method in Smalls.AllTypesFunction {code:java} public double toDouble(BigDecimal var) { return var.doubleValue(); } public double toDouble(Double var) { return var; } {code} when test it : {code:java} @Test public void testBigDecimalAndLong() { final CalciteAssert.AssertThat with = withUdf(); with.query("values \"adhoc\".\"toDouble\"(cast(1.0 as double))") .returns("EXPR$0=1.0\n"); }{code} where price is a double value in table tb, exception occurs: {code:java} java.lang.AssertionError at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:153) at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:627) at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:593) at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:447) at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5053) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5040) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1588) at
[jira] [Updated] (CALCITE-2053) Overloaded user-defined functions that have Double and BigDecimal arguments will goes wrong
[ https://issues.apache.org/jira/browse/CALCITE-2053?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] yuqi updated CALCITE-2053: -- Description: We add the following udf method in Smalls.AllTypesFunction {code:java} public double toDouble(Double var) { return var; } public double toDouble(BigDecimal var) { return var.doubleValue(); } {code} when test it : {code:java} @Test public void testBigDecimalAndLong() { final CalciteAssert.AssertThat with = withUdf(); with.query("values \"adhoc\".\"toDouble\"(cast(1.0 as double))") .returns("EXPR$0=1.0\n"); }{code} where price is a double value in table tb, exception occurs: {code:java} java.lang.AssertionError at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:153) at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:627) at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:593) at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:447) at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5053) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5040) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1588) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1573) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:225) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:4764) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:114) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:224) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:4764) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:114) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:895) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:605) at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:550) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:264) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:228) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:784) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:639) at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:609) at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:214) at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603) at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) {code} was: We define a udf function class have two function as follows {code:java} public double toDouble(Double var) { return var; } public double toDouble(BigDecimal var) { return var.doubleValue(); } {code} when use it in sql like: {code:sql} select sum(price) from tb; {code} where price is a double value in table tb, exception occurs: {code:java} java.lang.AssertionError: DECIMAL(19, 0) at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:154) at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:626) at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:592) at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:446) at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5371) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5358) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1592) at
[jira] [Updated] (CALCITE-2053) Overloaded user-defined functions that have Double and BigDecimal arguments will goes wrong
[ https://issues.apache.org/jira/browse/CALCITE-2053?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] yuqi updated CALCITE-2053: -- Description: We add the following udf method in Smalls.AllTypesFunction {code:java} public double toDouble(BigDecimal var) { return var.doubleValue(); } public double toDouble(Double var) { return var; } {code} when test it : {code:java} @Test public void testBigDecimalAndLong() { final CalciteAssert.AssertThat with = withUdf(); with.query("values \"adhoc\".\"toDouble\"(cast(1.0 as double))") .returns("EXPR$0=1.0\n"); }{code} where price is a double value in table tb, exception occurs: {code:java} java.lang.AssertionError at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:153) at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:627) at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:593) at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:447) at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5053) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5040) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1588) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1573) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:225) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:4764) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:114) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:224) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:4764) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:114) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:895) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:605) at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:550) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:264) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:228) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:784) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:639) at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:609) at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:214) at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603) at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) {code} was: We add the following udf method in Smalls.AllTypesFunction {code:java} public double toDouble(Double var) { return var; } public double toDouble(BigDecimal var) { return var.doubleValue(); } {code} when test it : {code:java} @Test public void testBigDecimalAndLong() { final CalciteAssert.AssertThat with = withUdf(); with.query("values \"adhoc\".\"toDouble\"(cast(1.0 as double))") .returns("EXPR$0=1.0\n"); }{code} where price is a double value in table tb, exception occurs: {code:java} java.lang.AssertionError at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:153) at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:627) at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:593) at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:447) at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:371) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:245) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5053) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5040) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1588) at
[jira] [Commented] (CALCITE-2046) Support "CREATE FUNCTION" DDL
[ https://issues.apache.org/jira/browse/CALCITE-2046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16347775#comment-16347775 ] Julian Hyde commented on CALCITE-2046: -- We already have Function, ScalarFunction, AggregateFunction and TableFunction in org.apache.calcite.schema. Are they sufficient? (There is some documentation in http://calcite.apache.org/docs/adapter.html#functions-and-operators, but to really understand how to use them, read UdfTest.) We can also load classes and methods as UDFs even if they do not implement an interface. Perhaps we could add an interface Extension and add some annotations to indicate which methods to load as functions. (This should be a secondary task.) As I said previously, I don't like {{CREATE FUNCTION ... USING JAR}} because it doesn't create one function, it creates several. Oracle has {{CREATE LIBRARY}}, so how about the following? {code}CREATE LIBRARY libraryName AS fullClassPath USING JAR 'jarPath' [, 'jarPath' ]...{code} It creates a named object so we could add {{ALTER LIBRARY}} and {{DROP LIBRARY}} later, to implement a full life-cycle. > Support "CREATE FUNCTION" DDL > - > > Key: CALCITE-2046 > URL: https://issues.apache.org/jira/browse/CALCITE-2046 > Project: Calcite > Issue Type: New Feature >Reporter: Shuyi Chen >Assignee: Julian Hyde >Priority: Major > > We want to add DDL support for creating external function like Apache Drill > ([https://drill.apache.org/docs/create-function-using-jar/]). > {code:java} > CREATE FUNCTION USING JAR '.jar'; > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2083) Update Avatica documentation
[ https://issues.apache.org/jira/browse/CALCITE-2083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16347739#comment-16347739 ] ASF GitHub Bot commented on CALCITE-2083: - Github user asfgit closed the pull request at: https://github.com/apache/calcite-avatica/pull/20 > Update Avatica documentation > > > Key: CALCITE-2083 > URL: https://issues.apache.org/jira/browse/CALCITE-2083 > Project: Calcite > Issue Type: Bug >Reporter: Michael Mior >Assignee: Michael Mior >Priority: Major > > The documentation doesn't explain how Avatica is a (semi-)separate project > and lists the old location of the Go driver. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2059) Apache Geode adapter
[ https://issues.apache.org/jira/browse/CALCITE-2059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16347714#comment-16347714 ] Michael Mior commented on CALCITE-2059: --- Thanks [~tzolov]! I probably should have updated this issue as well. Thanks for catching up with this! > Apache Geode adapter > > > Key: CALCITE-2059 > URL: https://issues.apache.org/jira/browse/CALCITE-2059 > Project: Calcite > Issue Type: New Feature >Reporter: Christian Tzolov >Assignee: Julian Hyde >Priority: Major > > I've been working on a Calcite adapter for [Apache > Geode|http://geode.apache.org]. > Current implementation uses the plain Geode API and > [OQL|http://geode.apache.org/docs/guide/13/developing/querying_basics/chapter_overview.html](Object > Query Interface) to push down relational expressions such as projections, > filtering, sorting, and grouping . > Provided functionality can hopefully address certain Geode use cases and will > provide a stepping stone for future improvements. > Here are some remaining tasks as i see it: > * New tests for test suite (and update calcite-test-dataset to support Geode) > * Add Integration tests that use calcite-test-dataset > * Documentation -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2083) Update Avatica documentation
[ https://issues.apache.org/jira/browse/CALCITE-2083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16347028#comment-16347028 ] ASF GitHub Bot commented on CALCITE-2083: - Github user joshelser commented on the issue: https://github.com/apache/calcite-avatica/pull/20 +1 > Update Avatica documentation > > > Key: CALCITE-2083 > URL: https://issues.apache.org/jira/browse/CALCITE-2083 > Project: Calcite > Issue Type: Bug >Reporter: Michael Mior >Assignee: Michael Mior >Priority: Major > > The documentation doesn't explain how Avatica is a (semi-)separate project > and lists the old location of the Go driver. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2155) upgrade slf4j
[ https://issues.apache.org/jira/browse/CALCITE-2155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16347022#comment-16347022 ] Josh Elser commented on CALCITE-2155: - [~alexeyroytman], has the API changed between versions? > upgrade slf4j > - > > Key: CALCITE-2155 > URL: https://issues.apache.org/jira/browse/CALCITE-2155 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.15.0 >Reporter: Alexey Roytman >Assignee: Julian Hyde >Priority: Major > > Apache Calcite depends on slf4j-api version 1.7.13 which was released on > 2015-11, more than two years ago. > We may wish to upgrade it to later version. For 2018-01-30, it's 1.7.25. > I hope that fixing pom.xml files and running tests is enough. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CALCITE-2059) Apache Geode adapter
[ https://issues.apache.org/jira/browse/CALCITE-2059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16346426#comment-16346426 ] Christian Tzolov commented on CALCITE-2059: --- I'm sorry [~julianhyde], i've completely missed [~michaelmior] 's review. Will try to address the comments by the end of the weeks. > Apache Geode adapter > > > Key: CALCITE-2059 > URL: https://issues.apache.org/jira/browse/CALCITE-2059 > Project: Calcite > Issue Type: New Feature >Reporter: Christian Tzolov >Assignee: Julian Hyde >Priority: Major > > I've been working on a Calcite adapter for [Apache > Geode|http://geode.apache.org]. > Current implementation uses the plain Geode API and > [OQL|http://geode.apache.org/docs/guide/13/developing/querying_basics/chapter_overview.html](Object > Query Interface) to push down relational expressions such as projections, > filtering, sorting, and grouping . > Provided functionality can hopefully address certain Geode use cases and will > provide a stepping stone for future improvements. > Here are some remaining tasks as i see it: > * New tests for test suite (and update calcite-test-dataset to support Geode) > * Add Integration tests that use calcite-test-dataset > * Documentation -- This message was sent by Atlassian JIRA (v7.6.3#76005)