Repository: phoenix Updated Branches: refs/heads/calcite 5c084d5ff -> e37387d65
PHOENIX-3984 PDataType to Calcite type conversion should consider whether precision or scale allowed for type in Calcite-addendum Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e37387d6 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e37387d6 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e37387d6 Branch: refs/heads/calcite Commit: e37387d653146b3a1c89d024c840f0a184bbbd2f Parents: 5c084d5 Author: Rajeshbabu Chintaguntla <[email protected]> Authored: Thu Jun 29 10:42:16 2017 +0530 Committer: Rajeshbabu Chintaguntla <[email protected]> Committed: Thu Jun 29 10:42:16 2017 +0530 ---------------------------------------------------------------------- .../apache/phoenix/calcite/CalciteUtils.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/e37387d6/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java index 557ad53..ecb7f0d 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java @@ -228,14 +228,22 @@ public class CalciteUtils { final PDataType normalizedBaseType = PDataType.fromTypeId(sqlTypeId); final SqlTypeName sqlTypeName = SqlTypeName.valueOf(normalizedBaseType.getSqlTypeName()); RelDataType type; - if (sqlTypeName.allowsNoPrecNoScale() - || (sqlTypeName.allowsPrecNoScale() && maxLength == null) - || (sqlTypeName.allowsScale() && maxLength == null && scale == null)) { - type = typeFactory.createSqlType(sqlTypeName); + if(sqlTypeName.allowsScale()) { + if(maxLength != null && scale != null) { + type = typeFactory.createSqlType(sqlTypeName, maxLength, scale); + } else if(maxLength != null) { + type = typeFactory.createSqlType(sqlTypeName, maxLength); + } else { + type = typeFactory.createSqlType(sqlTypeName); + } } else if(sqlTypeName.allowsPrecNoScale()) { - type = typeFactory.createSqlType(sqlTypeName, maxLength); + if(maxLength != null) { + type = typeFactory.createSqlType(sqlTypeName, maxLength); + } else { + type = typeFactory.createSqlType(sqlTypeName); + } } else { - type = typeFactory.createSqlType(sqlTypeName, maxLength, scale); + type = typeFactory.createSqlType(sqlTypeName); } if (isArrayType) { type = typeFactory.createArrayType(type, arraySize == null ? -1 : arraySize);
