Search in sources :

Example 6 with InvalidTableException

use of org.apache.hadoop.hive.ql.metadata.InvalidTableException in project hive by apache.

the class SemanticAnalyzer method validateAnalyzeNoscan.

/**
   * Validate noscan command
   *
   * @param tree
   * @throws SemanticException
   */
private void validateAnalyzeNoscan(ASTNode tree) throws SemanticException {
    // since it is noscan, it is true table name in command
    String tableName = getUnescapedName((ASTNode) tree.getChild(0).getChild(0));
    Table tbl;
    try {
        tbl = this.getTableObjectByName(tableName);
    } catch (InvalidTableException e) {
        throw new SemanticException(ErrorMsg.INVALID_TABLE.getMsg(tableName), e);
    } catch (HiveException e) {
        throw new SemanticException(e.getMessage(), e);
    }
    /* A nice error message should be given to user. */
    if (tbl.isNonNative()) {
        throw new SemanticException(ErrorMsg.ANALYZE_TABLE_NOSCAN_NON_NATIVE.getMsg(tbl.getTableName()));
    }
}
Also used : Table(org.apache.hadoop.hive.ql.metadata.Table) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) InvalidTableException(org.apache.hadoop.hive.ql.metadata.InvalidTableException) CalciteSemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)

Example 7 with InvalidTableException

use of org.apache.hadoop.hive.ql.metadata.InvalidTableException in project hive by apache.

the class UpdateDeleteSemanticAnalyzer method getTargetTable.

/**
   * @return the Metastore representation of the target table
   */
private Table getTargetTable(ASTNode tabRef) throws SemanticException {
    String[] tableName;
    Table mTable;
    switch(tabRef.getType()) {
        case HiveParser.TOK_TABREF:
            tableName = getQualifiedTableName((ASTNode) tabRef.getChild(0));
            break;
        case HiveParser.TOK_TABNAME:
            tableName = getQualifiedTableName(tabRef);
            break;
        default:
            throw raiseWrongType("TOK_TABREF|TOK_TABNAME", tabRef);
    }
    try {
        mTable = db.getTable(tableName[0], tableName[1]);
    } catch (InvalidTableException e) {
        LOG.error("Failed to find table " + getDotName(tableName) + " got exception " + e.getMessage());
        throw new SemanticException(ErrorMsg.INVALID_TABLE.getMsg(getDotName(tableName)), e);
    } catch (HiveException e) {
        LOG.error("Failed to find table " + getDotName(tableName) + " got exception " + e.getMessage());
        throw new SemanticException(e.getMessage(), e);
    }
    return mTable;
}
Also used : Table(org.apache.hadoop.hive.ql.metadata.Table) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) InvalidTableException(org.apache.hadoop.hive.ql.metadata.InvalidTableException)

Aggregations

InvalidTableException (org.apache.hadoop.hive.ql.metadata.InvalidTableException)7 Table (org.apache.hadoop.hive.ql.metadata.Table)7 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)3 CalciteSemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Tree (org.antlr.runtime.tree.Tree)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 Index (org.apache.hadoop.hive.metastore.api.Index)1 ReadEntity (org.apache.hadoop.hive.ql.hooks.ReadEntity)1 DDLWork (org.apache.hadoop.hive.ql.plan.DDLWork)1 DropTableDesc (org.apache.hadoop.hive.ql.plan.DropTableDesc)1