Search in sources :

Example 11 with CreateTableDesc

use of org.apache.hadoop.hive.ql.ddl.table.create.CreateTableDesc in project hive by apache.

the class TestHiveDecimalParse method getColumnType.

private String getColumnType(String query) {
    Driver driver = createDriver();
    int rc = driver.compile(query, true);
    if (rc != 0) {
        return null;
    }
    QueryPlan plan = driver.getPlan();
    DDLTask task = (DDLTask) plan.getRootTasks().get(0);
    DDLWork work = task.getWork();
    CreateTableDesc spec = (CreateTableDesc) work.getDDLDesc();
    FieldSchema fs = spec.getCols().get(0);
    return fs.getType();
}
Also used : CreateTableDesc(org.apache.hadoop.hive.ql.ddl.table.create.CreateTableDesc) DDLWork(org.apache.hadoop.hive.ql.ddl.DDLWork) DDLTask(org.apache.hadoop.hive.ql.ddl.DDLTask) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) Driver(org.apache.hadoop.hive.ql.Driver) QueryPlan(org.apache.hadoop.hive.ql.QueryPlan)

Example 12 with CreateTableDesc

use of org.apache.hadoop.hive.ql.ddl.table.create.CreateTableDesc in project hive by apache.

the class DummySemanticAnalyzerHook1 method postAnalyze.

@Override
public void postAnalyze(HiveSemanticAnalyzerHookContext context, List<Task<?>> rootTasks) throws SemanticException {
    count = 0;
    if (!isCreateTable) {
        return;
    }
    CreateTableDesc desc = (CreateTableDesc) ((DDLTask) rootTasks.get(rootTasks.size() - 1)).getWork().getDDLDesc();
    Map<String, String> tblProps = desc.getTblProps();
    if (tblProps == null) {
        tblProps = new HashMap<String, String>();
    }
    tblProps.put("createdBy", DummyCreateTableHook.class.getName());
    tblProps.put("Message", "Hive rocks!! Count: " + myCount);
    LogHelper console = SessionState.getConsole();
    console.printError("DummySemanticAnalyzerHook1 Post: Hive rocks!! Count: " + myCount);
}
Also used : CreateTableDesc(org.apache.hadoop.hive.ql.ddl.table.create.CreateTableDesc) DDLTask(org.apache.hadoop.hive.ql.ddl.DDLTask) LogHelper(org.apache.hadoop.hive.ql.session.SessionState.LogHelper)

Aggregations

CreateTableDesc (org.apache.hadoop.hive.ql.ddl.table.create.CreateTableDesc)12 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)7 Path (org.apache.hadoop.fs.Path)5 DDLTask (org.apache.hadoop.hive.ql.ddl.DDLTask)5 HiveStorageHandler (org.apache.hadoop.hive.ql.metadata.HiveStorageHandler)5 Table (org.apache.hadoop.hive.ql.metadata.Table)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)4 FileNotFoundException (java.io.FileNotFoundException)3 SourceTable (org.apache.hadoop.hive.metastore.api.SourceTable)3 DDLWork (org.apache.hadoop.hive.ql.ddl.DDLWork)3 CreateMaterializedViewDesc (org.apache.hadoop.hive.ql.ddl.view.create.CreateMaterializedViewDesc)3 CalciteSemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)3 LoadTableDesc (org.apache.hadoop.hive.ql.plan.LoadTableDesc)3 TableDesc (org.apache.hadoop.hive.ql.plan.TableDesc)3 AccessControlException (java.security.AccessControlException)2 LinkedList (java.util.LinkedList)2