Repository: phoenix Updated Branches: refs/heads/calcite e7bfd6468 -> 5c084d5ff
PHOENIX-3984 PDataType to Calcite type conversion should consider whether precision or scale allowed for type in Calcite(Rajeshbabu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/5c084d5f Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/5c084d5f Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/5c084d5f Branch: refs/heads/calcite Commit: 5c084d5ff3ae392326ba9455fb2aac1a879cc56b Parents: e7bfd64 Author: Rajeshbabu Chintaguntla <[email protected]> Authored: Thu Jun 29 08:41:42 2017 +0530 Committer: Rajeshbabu Chintaguntla <[email protected]> Committed: Thu Jun 29 08:41:42 2017 +0530 ---------------------------------------------------------------------- .../java/org/apache/phoenix/calcite/CalciteUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/5c084d5f/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 906fd71..557ad53 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,12 +228,14 @@ public class CalciteUtils { final PDataType normalizedBaseType = PDataType.fromTypeId(sqlTypeId); final SqlTypeName sqlTypeName = SqlTypeName.valueOf(normalizedBaseType.getSqlTypeName()); RelDataType type; - if (maxLength != null && scale != null) { - type = typeFactory.createSqlType(sqlTypeName, maxLength, scale); - } else if (maxLength != null) { + if (sqlTypeName.allowsNoPrecNoScale() + || (sqlTypeName.allowsPrecNoScale() && maxLength == null) + || (sqlTypeName.allowsScale() && maxLength == null && scale == null)) { + type = typeFactory.createSqlType(sqlTypeName); + } else if(sqlTypeName.allowsPrecNoScale()) { type = typeFactory.createSqlType(sqlTypeName, maxLength); } else { - type = typeFactory.createSqlType(sqlTypeName); + type = typeFactory.createSqlType(sqlTypeName, maxLength, scale); } if (isArrayType) { type = typeFactory.createArrayType(type, arraySize == null ? -1 : arraySize);
