[CALCITE-3429] AssertionError for user-defined table function with map argument#1521
[CALCITE-3429] AssertionError for user-defined table function with map argument#1521yanlin-Lynn wants to merge 1 commit intoapache:masterfrom
Conversation
03fae49 to
b7d83ba
Compare
core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java
Outdated
Show resolved
Hide resolved
c56ce7a to
e91f07d
Compare
|
Can we avoid to use |
7e0e168 to
4b9707b
Compare
4b9707b to
9920103
Compare
| + "postalCode,country,phoneNumber,addressTag]\n" | ||
| + "primaryAddress=PDX[addressLine1,addressLine2,addressLine3,city,state,postalCode," | ||
| + "country,phoneNumber,addressTag]\n") | ||
| .returns(new Consumer<ResultSet>() { |
There was a problem hiding this comment.
I update this case to make it pass.
But I'm not quite familiar with the logic, hopes someone more familiar with it can review this.
Sure, I'll avoid this next time. |
| * Using ANY type as value type. | ||
| */ | ||
| @Override public RelDataType getValueType() { | ||
| if (Map.class.isAssignableFrom(clazz)) { |
There was a problem hiding this comment.
Does any code use these 2 methods ?
There was a problem hiding this comment.
yes, inSqlItemOperator.
If don't override these 2 methods, running org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest will get NullPointerException
Caused by: java.lang.NullPointerException
at org.apache.calcite.sql.fun.SqlItemOperator.getChecker(SqlItemOperator.java:103)
at org.apache.calcite.sql.fun.SqlItemOperator.checkOperandTypes(SqlItemOperator.java:91)
at org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:432)
at org.apache.calcite.sql.SqlOperator.deriveType(SqlOperator.java:518)
at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5639)
at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5626)
at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1692)
at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1677)
at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:480)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4117)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3396)
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:1009)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:969)
at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
| */ | ||
| @Override public RelDataType getKeyType() { | ||
| if (Map.class.isAssignableFrom(clazz)) { | ||
| return createSqlType(SqlTypeName.ANY); |
There was a problem hiding this comment.
Say the map is by Integer -> Integer
Why return SqlTypeName.ANY here ?
There was a problem hiding this comment.
Because I cannot find a way to get the Integer parameter type when create type with Map class.
And use SqlTypeName.ANY can cover other types.
5128659 to
5ff8d44
Compare
|
hi, @danny0405 |
80f411d to
ca27fe9
Compare
5ff8d44 to
8460d67
Compare
…p argument (Wang Yanlin) 1. Add map info from Java Map class to SqlTypeName.Map 2. SqlTypeName.Map is not a basic type, should not be used in factory method "createSqlType", just like SqlTypeName.Array 3. Add coerce rule for SqlTypeName.MAP
8460d67 to
758079a
Compare
|
Sorry for the delay, reviewing now ~ |
…p argument (Wang Yanlin) 1. Add map info from Java Map class to SqlTypeName.Map 2. SqlTypeName.Map is not a basic type, should not be used in factory method "createSqlType", just like SqlTypeName.Array 3. Add coerce rule for SqlTypeName.MAP Fix-up(by Danny): * Fix GeodeTable#query field type inference; * Fix GeodeUtils#convert for nested PdxInstance because in JavaTypeFactoryExtImpl#createPdxType, the nested PdxInstance is inferred as Map type(we can not describe nested JavaType correctly now). close apache#1521
…p argument (Wang Yanlin) 1. Add map info from Java Map class to SqlTypeName.Map 2. SqlTypeName.Map is not a basic type, should not be used in factory method "createSqlType", just like SqlTypeName.Array 3. Add coerce rule for SqlTypeName.MAP Fix-up(by Danny): * Fix GeodeTable#query field type inference; * Fix GeodeUtils#convert for nested PdxInstance because in JavaTypeFactoryExtImpl#createPdxType, the nested PdxInstance is inferred as Map type(we can not describe nested JavaType correctly now). close apache#1521 Change-Id: If1449d398b20914614dc573ee15d999b24223c3d
apache#124) …p argument (Wang Yanlin) 1. Add map info from Java Map class to SqlTypeName.Map 2. SqlTypeName.Map is not a basic type, should not be used in factory method "createSqlType", just like SqlTypeName.Array 3. Add coerce rule for SqlTypeName.MAP Fix-up(by Danny): * Fix GeodeTable#query field type inference; * Fix GeodeUtils#convert for nested PdxInstance because in JavaTypeFactoryExtImpl#createPdxType, the nested PdxInstance is inferred as Map type(we can not describe nested JavaType correctly now). close apache#1521 Change-Id: If1449d398b20914614dc573ee15d999b24223c3d
…p argument (Wang Yanlin) 1. Add map info from Java Map class to SqlTypeName.Map 2. SqlTypeName.Map is not a basic type, should not be used in factory method "createSqlType", just like SqlTypeName.Array 3. Add coerce rule for SqlTypeName.MAP Fix-up(by Danny): * Fix GeodeTable#query field type inference; * Fix GeodeUtils#convert for nested PdxInstance because in JavaTypeFactoryExtImpl#createPdxType, the nested PdxInstance is inferred as Map type(we can not describe nested JavaType correctly now). close apache#1521 Change-Id: If1449d398b20914614dc573ee15d999b24223c3d
Similar to #1519, using map in table function may cause exception.
Please refer to jira CALCITE-3429 for full stack trace.
To fix it, this PR make the follow changes:
createSqlType, just like SqlTypeName.Array