|
17 | 17 | */ |
18 | 18 | package org.apache.drill.exec.planner.sql; |
19 | 19 |
|
20 | | -import org.apache.calcite.sql.fun.SqlStdOperatorTable; |
21 | 20 | import com.google.common.collect.ImmutableMap; |
22 | 21 | import com.google.common.collect.ImmutableSet; |
23 | 22 | import com.google.common.collect.Lists; |
24 | | -import org.slf4j.Logger; |
25 | | -import org.slf4j.LoggerFactory; |
26 | 23 | import org.apache.calcite.avatica.util.TimeUnit; |
27 | 24 | import org.apache.calcite.rel.type.RelDataType; |
28 | 25 | import org.apache.calcite.rel.type.RelDataTypeFactory; |
|
35 | 32 | import org.apache.calcite.sql.SqlNode; |
36 | 33 | import org.apache.calcite.sql.SqlNumericLiteral; |
37 | 34 | import org.apache.calcite.sql.SqlOperatorBinding; |
| 35 | +import org.apache.calcite.sql.fun.SqlStdOperatorTable; |
38 | 36 | import org.apache.calcite.sql.parser.SqlParserPos; |
39 | 37 | import org.apache.calcite.sql.type.SqlReturnTypeInference; |
40 | 38 | import org.apache.calcite.sql.type.SqlTypeFamily; |
41 | 39 | import org.apache.calcite.sql.type.SqlTypeName; |
42 | | - |
| 40 | +import org.apache.calcite.util.NlsString; |
| 41 | +import org.apache.drill.common.exceptions.UserException; |
43 | 42 | import org.apache.drill.common.expression.ExpressionPosition; |
44 | 43 | import org.apache.drill.common.expression.FunctionCall; |
45 | 44 | import org.apache.drill.common.expression.FunctionCallFactory; |
46 | 45 | import org.apache.drill.common.expression.LogicalExpression; |
47 | 46 | import org.apache.drill.common.expression.MajorTypeInLogicalExpression; |
48 | | -import org.apache.drill.common.exceptions.UserException; |
49 | 47 | import org.apache.drill.common.types.TypeProtos; |
50 | 48 | import org.apache.drill.common.types.Types; |
51 | 49 | import org.apache.drill.exec.expr.annotations.FunctionTemplate; |
|
54 | 52 | import org.apache.drill.exec.resolver.FunctionResolver; |
55 | 53 | import org.apache.drill.exec.resolver.FunctionResolverFactory; |
56 | 54 | import org.apache.drill.exec.resolver.TypeCastRules; |
| 55 | +import org.slf4j.Logger; |
| 56 | +import org.slf4j.LoggerFactory; |
57 | 57 |
|
58 | 58 | import java.util.List; |
59 | 59 | import java.util.Optional; |
@@ -744,7 +744,7 @@ public RelDataType inferReturnType(SqlOperatorBinding opBinding) { |
744 | 744 | } |
745 | 745 |
|
746 | 746 | final String part = ((SqlCharStringLiteral) ((SqlCallBinding) opBinding).operand(0)) |
747 | | - .getNlsString() |
| 747 | + .getValueAs(NlsString.class) |
748 | 748 | .getValue() |
749 | 749 | .toUpperCase(); |
750 | 750 |
|
@@ -1023,14 +1023,19 @@ public static RelDataType createCalciteTypeWithNullability(RelDataTypeFactory ty |
1023 | 1023 | public static RelDataType convertToCalciteType(RelDataTypeFactory typeFactory, |
1024 | 1024 | TypeProtos.MajorType drillType, boolean isNullable) { |
1025 | 1025 | SqlTypeName sqlTypeName = getCalciteTypeFromDrillType(drillType.getMinorType()); |
| 1026 | + int precision; |
| 1027 | + int scale; |
| 1028 | + |
1026 | 1029 | switch (sqlTypeName) { |
1027 | 1030 | case DECIMAL: |
| 1031 | + precision = drillType.getPrecision(); |
| 1032 | + scale = drillType.getScale(); |
1028 | 1033 | return typeFactory.createTypeWithNullability( |
1029 | | - typeFactory.createSqlType(sqlTypeName, drillType.getPrecision(), |
1030 | | - drillType.getScale()), isNullable); |
| 1034 | + typeFactory.createSqlType(sqlTypeName, precision, |
| 1035 | + scale), isNullable); |
1031 | 1036 | case TIME: |
1032 | 1037 | case TIMESTAMP: |
1033 | | - int precision = drillType.hasPrecision() |
| 1038 | + precision = drillType.hasPrecision() |
1034 | 1039 | ? drillType.getPrecision() |
1035 | 1040 | : typeFactory.getTypeSystem().getDefaultPrecision(sqlTypeName); |
1036 | 1041 | return typeFactory.createTypeWithNullability( |
|
0 commit comments