FAQ
Repository: hive
Updated Branches:
   refs/heads/master 2b1f03e33 -> 7fe23aa1c


HIVE-11282: CBO (Calcite Return Path): Inferring Hive type char/varchar of length zero which is not allowed (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/7fe23aa1
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/7fe23aa1
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/7fe23aa1

Branch: refs/heads/master
Commit: 7fe23aa1c6a6abd96717b44790033b49f13e550f
Parents: 2b1f03e
Author: Jesus Camacho Rodriguez <jcamacho@apache.org>
Authored: Fri Jul 17 20:08:14 2015 +0100
Committer: Jesus Camacho Rodriguez <jcamacho@apache.org>
Committed: Fri Jul 17 20:08:14 2015 +0100

----------------------------------------------------------------------
  .../calcite/translator/ExprNodeConverter.java | 24 +++++++++++++++-----
  1 file changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/7fe23aa1/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
index 4f0db03..955aa91 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
@@ -224,12 +224,24 @@ public class ExprNodeConverter extends RexVisitorImpl<ExprNodeDesc> {
      case DECIMAL:
        return new ExprNodeConstantDesc(TypeInfoFactory.getDecimalTypeInfo(lType.getPrecision(),
            lType.getScale()), literal.getValue3());
- case VARCHAR:
- return new ExprNodeConstantDesc(TypeInfoFactory.getVarcharTypeInfo(lType.getPrecision()),
- new HiveVarchar((String) literal.getValue3(), lType.getPrecision()));
- case CHAR:
- return new ExprNodeConstantDesc(TypeInfoFactory.getCharTypeInfo(lType.getPrecision()),
- new HiveChar((String) literal.getValue3(), lType.getPrecision()));
+ case VARCHAR: {
+ int varcharLength = lType.getPrecision();
+ // If we cannot use Varchar due to type length restrictions, we use String
+ if (varcharLength < 1 || varcharLength > HiveVarchar.MAX_VARCHAR_LENGTH) {
+ return new ExprNodeConstantDesc(TypeInfoFactory.stringTypeInfo, literal.getValue3());
+ }
+ return new ExprNodeConstantDesc(TypeInfoFactory.getVarcharTypeInfo(varcharLength),
+ new HiveVarchar((String) literal.getValue3(), varcharLength));
+ }
+ case CHAR: {
+ int charLength = lType.getPrecision();
+ // If we cannot use Char due to type length restrictions, we use String
+ if (charLength < 1 || charLength > HiveChar.MAX_CHAR_LENGTH) {
+ return new ExprNodeConstantDesc(TypeInfoFactory.stringTypeInfo, literal.getValue3());
+ }
+ return new ExprNodeConstantDesc(TypeInfoFactory.getCharTypeInfo(charLength),
+ new HiveChar((String) literal.getValue3(), charLength));
+ }
      case INTERVAL_YEAR_MONTH: {
        BigDecimal monthsBd = (BigDecimal) literal.getValue();
        return new ExprNodeConstantDesc(TypeInfoFactory.intervalYearMonthTypeInfo,

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedJul 17, '15 at 7:08p
activeJul 17, '15 at 7:08p
posts1
users1
websitehive.apache.org

1 user in discussion

Jcamacho: 1 post

People

Translate

site design / logo © 2021 Grokbase