private void reparseAndSuperAnalyze(Table table, URI fromURI) throws SemanticException {
    LOG.info("Load data triggered a Tez job instead of usual file operation");
    // Step 1 : Create a temp table object
    // Create a Table object
    Table tempTableObj = new Table(new org.apache.hadoop.hive.metastore.api.Table(table.getTTable()));
    // Construct a temp table name
    String tempTblName = table.getTableName() + tempTblNameSuffix;
    tempTableObj.setTableName(tempTblName);

    // Reset table params
    tempTableObj.setParameters(new HashMap<>());

    // Set data location and input format, it must be text
    tempTableObj.setDataLocation(new Path(fromURI));
    if (inputFormatClassName != null && serDeClassName != null) {
      try {
        tempTableObj.setInputFormatClass(inputFormatClassName);
        tempTableObj.setSerializationLib(serDeClassName);
      } catch (HiveException e) {
        throw new SemanticException("Load Data: Failed to set inputFormat or SerDe");
      }
    }

    // Make the columns list for the temp table (input data file).
    // Move all the partition columns at the end of table columns.
    List<FieldSchema> colList = new ArrayList<>(table.getCols());

    // inpPartSpec is a mapping from partition column name to its value.
    Map<String, String> inpPartSpec = null;

    // Partition spec was already validated by caller when create TableSpec object.
    // So, need not validate inpPartSpec here.
    List<FieldSchema> parts = table.getPartCols();
    if (tableTree.getChildCount() >= 2) {
      ASTNode partSpecNode = (ASTNode) tableTree.getChild(1);
      inpPartSpec = new HashMap<>(partSpecNode.getChildCount());

      for (int i = 0; i < partSpecNode.getChildCount(); ++i) {
        ASTNode partSpecValNode = (ASTNode) partSpecNode.getChild(i);
        String partVal = null;
        String partColName = unescapeIdentifier(partSpecValNode.getChild(0).getText().toLowerCase());

        if (partSpecValNode.getChildCount() >= 2) { // in the form of T partition (ds="2010-03-03")
          // Not stripping quotes here as we need to use it as it is while framing PARTITION clause
          // in INSERT query.
          partVal = partSpecValNode.getChild(1).getText();
        }
        inpPartSpec.put(partColName, partVal);
      }

      // Add only dynamic partition columns to the temp table (input data file).
      // For static partitions, values would be obtained from partition(key=value...) clause.
      for (FieldSchema fs : parts) {
        String partKey = fs.getName();

        // If a partition value is not there, then it is dynamic partition key.
        if (inpPartSpec.get(partKey) == null) {
          colList.add(fs);
        }
      }
    } else {
      // No static partitions specified and hence all are dynamic partition keys and need to be part
      // of temp table (input data file).
      colList.addAll(parts);
    }

    // Set columns list for temp table.
    tempTableObj.setFields(colList);

    // Wipe out partition columns
    tempTableObj.setPartCols(new ArrayList<>());

    // Step 2 : create the Insert query
    StringBuilder rewrittenQueryStr = new StringBuilder();

    if (isOverWrite) {
      rewrittenQueryStr.append("insert overwrite table ");
    } else {
      rewrittenQueryStr.append("insert into table ");
    }

    rewrittenQueryStr.append(getFullTableNameForSQL((ASTNode)(tableTree.getChild(0))));
    addPartitionColsToInsert(table.getPartCols(), inpPartSpec, rewrittenQueryStr);
    rewrittenQueryStr.append(" select * from ");
    rewrittenQueryStr.append(tempTblName);

    // Step 3 : parse the query
    // Set dynamic partitioning to nonstrict so that queries do not need any partition
    // references.
    HiveConf.setVar(conf, HiveConf.ConfVars.DYNAMIC_PARTITIONING_MODE, "nonstrict");
    // Parse the rewritten query string
    Context rewrittenCtx;
    rewrittenCtx = new Context(conf);
    // We keep track of all the contexts that are created by this query
    // so we can clear them when we finish execution
    ctx.addSubContext(rewrittenCtx);
    rewrittenCtx.setExplainConfig(ctx.getExplainConfig());
    rewrittenCtx.setExplainPlan(ctx.isExplainPlan());
    rewrittenCtx.setCmd(rewrittenQueryStr.toString());
    rewrittenCtx.setTempTableForLoad(tempTableObj);

    ASTNode rewrittenTree;
    try {
      LOG.info("Going to reparse <" + ctx.getCmd() + "> as \n<" + rewrittenQueryStr.toString() + ">");
      rewrittenTree = ParseUtils.parse(rewrittenQueryStr.toString(), rewrittenCtx);
    } catch (ParseException e) {
      throw new SemanticException(ErrorMsg.LOAD_DATA_LAUNCH_JOB_PARSE_ERROR.getMsg(), e);
    }

    // Step 4 : Reanalyze
    super.analyze(rewrittenTree, rewrittenCtx);

    queryReWritten = true;
  }
Verifies the file path existence. If the path is a directory, then it is
verified to not be a glob pattern. If the path is a file, then it is
verified to be a valid file name.
ql/src/java/org/apache/hadoop/hive/ql/parse/LoadSemanticAnalyzer.java