• 问题一:【Hive】explain command throw ClassCastException in 2.3.4


    参考:https://issues.apache.org/jira/browse/HIVE-21489


    (一)问题描述:

         Hive-2.3.4 执行  explain select * from src in hive-2.3.4

        报错: ClassCastException: org.apache.hadoop.hive.ql.parse.ExplainSemanticAnalyzer cannot be cast to org.apache.hadoop.hive.ql.parse.SemanticAnalyzer

    (二)解决方法

    1. 找到Hive-2.3.4 源码;
    2. 修改类:   /ql/src/java/org/apache/hadoop/hive/ql/Driver.java    
    diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
    index cac14a6..70a8028 100644
    --- a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
    +++ b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
    @@ -114,6 +114,7 @@
     import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer;
     import org.apache.hadoop.hive.ql.parse.ColumnAccessInfo;
     import org.apache.hadoop.hive.ql.parse.ExplainConfiguration.AnalyzeState;
    +import org.apache.hadoop.hive.ql.parse.ExplainSemanticAnalyzer;
     import org.apache.hadoop.hive.ql.parse.HiveSemanticAnalyzerHookContext;
     import org.apache.hadoop.hive.ql.parse.HiveSemanticAnalyzerHookContextImpl;
     import org.apache.hadoop.hive.ql.parse.ImportSemanticAnalyzer;
    @@ -1292,10 +1293,14 @@ private static void getTablePartitionUsedColumns(HiveOperation op, BaseSemanticA
         // (par2Cols) or
         // table to columns mapping (tab2Cols)
         if (op.equals(HiveOperation.CREATETABLE_AS_SELECT) || op.equals(HiveOperation.QUERY)) {
    -      SemanticAnalyzer querySem = (SemanticAnalyzer) sem;
    -      ParseContext parseCtx = querySem.getParseContext();
    +      ParseContext parseCtx;
    +      if (sem instanceof ExplainSemanticAnalyzer) {
    +        parseCtx = ((ExplainSemanticAnalyzer)sem).getParseContext();
    +      } else {
    +        parseCtx = ((SemanticAnalyzer)sem).getParseContext();
    +      }
     
    -      for (Map.Entry<String, TableScanOperator> topOpMap : querySem.getParseContext().getTopOps()
    +      for (Map.Entry<String, TableScanOperator> topOpMap : parseCtx.getTopOps()
               .entrySet()) {
             TableScanOperator tableScanOp = topOpMap.getValue();
             if (!tableScanOp.isInsideView()) {

             修改类 :/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java

    diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
    index 6d7af38..73ba8e3 100644
    --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
    +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ExplainSemanticAnalyzer.java
    @@ -56,6 +56,7 @@
     public class ExplainSemanticAnalyzer extends BaseSemanticAnalyzer {
       List<FieldSchema> fieldList;
       ExplainConfiguration config;
    +  ParseContext pCtx = null;
     
       public ExplainSemanticAnalyzer(QueryState queryState) throws SemanticException {
         super(queryState);
    @@ -189,7 +190,6 @@ public void analyzeInternal(ASTNode ast) throws SemanticException {
           fetchTask.getWork().initializeForFetch(ctx.getOpContext());
         }
     
    -    ParseContext pCtx = null;
         if (sem instanceof SemanticAnalyzer) {
           pCtx = ((SemanticAnalyzer)sem).getParseContext();
         }
    @@ -285,4 +285,7 @@ public boolean skipAuthorization() {
         return task instanceof ExplainTask && ((ExplainTask)task).getWork().isAuthorize();
       }
     
    +  public ParseContext getParseContext() {
    +    return pCtx;
    +  }
     }

             3. 编译生成class文件,替换hive-exec-2.3.4.jar

             4. 执行以下命令(如果配置有,则不需要)

    set hive.security.authorization.enabled=true;
    set hive.execution.engine=mr;
    set hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider;
  • 相关阅读:
    网络监听主要是基于ASIHTTPRequest内的Reachability的调用
    Quartz2D之渐变使用初步
    IOS检测网络连接状态(转)
    ios xcode如何修改应用的名称
    使用CAShapeLayer与UIBezierPath画出想要的图形
    JSONValue failed. Error is: Unescaped control character [0x09]
    ASIHTTPRequest和ASIFormDataRequest 区别,GET和POST
    ios 图片压缩
    利用dispatch_once创建单例
    利用预渲染加速iOS设备的图像显示
  • 原文地址:https://www.cnblogs.com/shix0909/p/11078695.html
Copyright © 2020-2023  润新知