hive git commit: HIVE-18857: Store default value text instead of default value expression in metastore(Vineet Garg, reviewed by Ashutosh Chauhan)
Repository: hive Updated Branches: refs/heads/branch-3 946f619e7 -> d1a935816 HIVE-18857: Store default value text instead of default value expression in metastore(Vineet Garg, 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/d1a93581 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/d1a93581 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/d1a93581 Branch: refs/heads/branch-3 Commit: d1a9358162f32ef489541cc72aef059e13349497 Parents: 946f619 Author: Vineet GargAuthored: Mon Apr 9 19:32:07 2018 -0700 Committer: Vineet Garg Committed: Mon Apr 9 19:32:07 2018 -0700 -- .../hadoop/hive/ql/parse/BaseSemanticAnalyzer.java | 15 +-- .../hadoop/hive/ql/parse/DDLSemanticAnalyzer.java| 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hive/blob/d1a93581/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java -- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java index 5301b2a..d940cdd 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java @@ -765,10 +765,11 @@ public abstract class BaseSemanticAnalyzer { } protected static void processDefaultConstraints(String catName, String databaseName, String tableName, - ASTNode child, List columnNames, List defaultConstraints, final ASTNode typeChild) + ASTNode child, List columnNames, List defaultConstraints, final ASTNode typeChild, + final TokenRewriteStream tokenRewriteStream) throws SemanticException { List defaultInfos = new ArrayList(); -generateConstraintInfos(child, columnNames, defaultInfos, typeChild, null); +generateConstraintInfos(child, columnNames, defaultInfos, typeChild, tokenRewriteStream); constraintInfosToDefaultConstraints(catName, databaseName, tableName, defaultInfos, defaultConstraints); } @@ -930,7 +931,8 @@ public abstract class BaseSemanticAnalyzer { * @return retrieve the default value and return it as string * @throws SemanticException */ - private static String getDefaultValue(ASTNode defaultValueAST, ASTNode typeChild) throws SemanticException{ + private static String getDefaultValue(ASTNode defaultValueAST, ASTNode typeChild, +final TokenRewriteStream tokenStream) throws SemanticException{ // first create expression from defaultValueAST TypeCheckCtx typeCheckCtx = new TypeCheckCtx(null); ExprNodeDesc defaultValExpr = TypeCheckProcFactory @@ -942,7 +944,8 @@ public abstract class BaseSemanticAnalyzer { } //get default value to be be stored in metastore -String defaultValueText = defaultValExpr.getExprString(); +String defaultValueText = tokenStream.toOriginalString(defaultValueAST.getTokenStartIndex(), + defaultValueAST.getTokenStopIndex()); final int DEFAULT_MAX_LEN = 255; if(defaultValueText.length() > DEFAULT_MAX_LEN) { throw new SemanticException( @@ -1026,7 +1029,7 @@ public abstract class BaseSemanticAnalyzer { rely = false; } else if( child.getToken().getType() == HiveParser.TOK_DEFAULT_VALUE){ // try to get default value only if this is DEFAULT constraint -checkOrDefaultValue = getDefaultValue(grandChild, typeChildForDefault); +checkOrDefaultValue = getDefaultValue(grandChild, typeChildForDefault, tokenRewriteStream); } else if(child.getToken().getType() == HiveParser.TOK_CHECK_CONSTRAINT) { checkOrDefaultValue = getCheckExpression(grandChild, tokenRewriteStream); @@ -1259,7 +1262,7 @@ public abstract class BaseSemanticAnalyzer { break; case HiveParser.TOK_DEFAULT_VALUE: processDefaultConstraints(catName, qualifiedTabName[0], qualifiedTabName[1], constraintChild, -ImmutableList.of(col.getName()), defaultConstraints, typeChild); +ImmutableList.of(col.getName()), defaultConstraints, typeChild, tokenRewriteStream); break; case HiveParser.TOK_NOT_NULL: processNotNullConstraints(catName, qualifiedTabName[0], qualifiedTabName[1], constraintChild, http://git-wip-us.apache.org/repos/asf/hive/blob/d1a93581/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
hive git commit: HIVE-18857: Store default value text instead of default value expression in metastore(Vineet Garg, reviewed by Ashutosh Chauhan)
Repository: hive Updated Branches: refs/heads/master 55fb0a196 -> 2e92451a6 HIVE-18857: Store default value text instead of default value expression in metastore(Vineet Garg, 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/2e92451a Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/2e92451a Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/2e92451a Branch: refs/heads/master Commit: 2e92451a61557248e47453e7917d81c428379bfa Parents: 55fb0a1 Author: Vineet GargAuthored: Mon Apr 9 19:31:14 2018 -0700 Committer: Vineet Garg Committed: Mon Apr 9 19:31:14 2018 -0700 -- .../hadoop/hive/ql/parse/BaseSemanticAnalyzer.java | 15 +-- .../hadoop/hive/ql/parse/DDLSemanticAnalyzer.java| 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hive/blob/2e92451a/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java -- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java index 5301b2a..d940cdd 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java @@ -765,10 +765,11 @@ public abstract class BaseSemanticAnalyzer { } protected static void processDefaultConstraints(String catName, String databaseName, String tableName, - ASTNode child, List columnNames, List defaultConstraints, final ASTNode typeChild) + ASTNode child, List columnNames, List defaultConstraints, final ASTNode typeChild, + final TokenRewriteStream tokenRewriteStream) throws SemanticException { List defaultInfos = new ArrayList(); -generateConstraintInfos(child, columnNames, defaultInfos, typeChild, null); +generateConstraintInfos(child, columnNames, defaultInfos, typeChild, tokenRewriteStream); constraintInfosToDefaultConstraints(catName, databaseName, tableName, defaultInfos, defaultConstraints); } @@ -930,7 +931,8 @@ public abstract class BaseSemanticAnalyzer { * @return retrieve the default value and return it as string * @throws SemanticException */ - private static String getDefaultValue(ASTNode defaultValueAST, ASTNode typeChild) throws SemanticException{ + private static String getDefaultValue(ASTNode defaultValueAST, ASTNode typeChild, +final TokenRewriteStream tokenStream) throws SemanticException{ // first create expression from defaultValueAST TypeCheckCtx typeCheckCtx = new TypeCheckCtx(null); ExprNodeDesc defaultValExpr = TypeCheckProcFactory @@ -942,7 +944,8 @@ public abstract class BaseSemanticAnalyzer { } //get default value to be be stored in metastore -String defaultValueText = defaultValExpr.getExprString(); +String defaultValueText = tokenStream.toOriginalString(defaultValueAST.getTokenStartIndex(), + defaultValueAST.getTokenStopIndex()); final int DEFAULT_MAX_LEN = 255; if(defaultValueText.length() > DEFAULT_MAX_LEN) { throw new SemanticException( @@ -1026,7 +1029,7 @@ public abstract class BaseSemanticAnalyzer { rely = false; } else if( child.getToken().getType() == HiveParser.TOK_DEFAULT_VALUE){ // try to get default value only if this is DEFAULT constraint -checkOrDefaultValue = getDefaultValue(grandChild, typeChildForDefault); +checkOrDefaultValue = getDefaultValue(grandChild, typeChildForDefault, tokenRewriteStream); } else if(child.getToken().getType() == HiveParser.TOK_CHECK_CONSTRAINT) { checkOrDefaultValue = getCheckExpression(grandChild, tokenRewriteStream); @@ -1259,7 +1262,7 @@ public abstract class BaseSemanticAnalyzer { break; case HiveParser.TOK_DEFAULT_VALUE: processDefaultConstraints(catName, qualifiedTabName[0], qualifiedTabName[1], constraintChild, -ImmutableList.of(col.getName()), defaultConstraints, typeChild); +ImmutableList.of(col.getName()), defaultConstraints, typeChild, tokenRewriteStream); break; case HiveParser.TOK_NOT_NULL: processNotNullConstraints(catName, qualifiedTabName[0], qualifiedTabName[1], constraintChild, http://git-wip-us.apache.org/repos/asf/hive/blob/2e92451a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java