Search in sources :

Example 11 with QueryState

use of org.apache.hadoop.hive.ql.QueryState in project hive by apache.

the class TestUpdateDeleteSemanticAnalyzer method setup.

@Before
public void setup() {
    queryState = new QueryState(null);
    conf = queryState.getConf();
    conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    conf.setVar(HiveConf.ConfVars.DYNAMICPARTITIONINGMODE, "nonstrict");
    conf.setVar(HiveConf.ConfVars.HIVEMAPREDMODE, "nonstrict");
    conf.setVar(HiveConf.ConfVars.HIVE_TXN_MANAGER, "org.apache.hadoop.hive.ql.lockmgr.DbTxnManager");
}
Also used : QueryState(org.apache.hadoop.hive.ql.QueryState) Before(org.junit.Before)

Example 12 with QueryState

use of org.apache.hadoop.hive.ql.QueryState in project hive by apache.

the class TestHiveAuthorizationTaskFactory method setup.

@Before
public void setup() throws Exception {
    queryState = new QueryState(null);
    HiveConf conf = queryState.getConf();
    conf.setVar(ConfVars.HIVE_AUTHORIZATION_TASK_FACTORY, TestHiveAuthorizationTaskFactory.DummyHiveAuthorizationTaskFactoryImpl.class.getName());
    conf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    db = Mockito.mock(Hive.class);
    table = new Table(DB, TABLE);
    partition = new Partition(table);
    SessionState.start(conf);
    context = new Context(conf);
    parseDriver = new ParseDriver();
    analyzer = new DDLSemanticAnalyzer(queryState, db);
    Mockito.when(db.getTable(DB, TABLE, false)).thenReturn(table);
    Mockito.when(db.getTable(TABLE_QNAME, false)).thenReturn(table);
    Mockito.when(db.getPartition(table, new HashMap<String, String>(), false)).thenReturn(partition);
    HadoopDefaultAuthenticator auth = new HadoopDefaultAuthenticator();
    auth.setConf(conf);
    currentUser = auth.getUserName();
    DummyHiveAuthorizationTaskFactoryImpl.reset();
}
Also used : Context(org.apache.hadoop.hive.ql.Context) Partition(org.apache.hadoop.hive.ql.metadata.Partition) Hive(org.apache.hadoop.hive.ql.metadata.Hive) Table(org.apache.hadoop.hive.ql.metadata.Table) ParseDriver(org.apache.hadoop.hive.ql.parse.ParseDriver) HiveConf(org.apache.hadoop.hive.conf.HiveConf) QueryState(org.apache.hadoop.hive.ql.QueryState) HadoopDefaultAuthenticator(org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator) DDLSemanticAnalyzer(org.apache.hadoop.hive.ql.parse.DDLSemanticAnalyzer) Before(org.junit.Before)

Example 13 with QueryState

use of org.apache.hadoop.hive.ql.QueryState in project hive by apache.

the class TestPrivilegesV1 method setup.

@Before
public void setup() throws Exception {
    queryState = new QueryState(null);
    db = Mockito.mock(Hive.class);
    table = new Table(DB, TABLE);
    partition = new Partition(table);
    HiveConf hiveConf = queryState.getConf();
    hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    SessionState.start(hiveConf);
    Mockito.when(db.getTable(DB, TABLE, false)).thenReturn(table);
    Mockito.when(db.getTable(TABLE_QNAME, false)).thenReturn(table);
    Mockito.when(db.getPartition(table, new HashMap<String, String>(), false)).thenReturn(partition);
}
Also used : Partition(org.apache.hadoop.hive.ql.metadata.Partition) Hive(org.apache.hadoop.hive.ql.metadata.Hive) Table(org.apache.hadoop.hive.ql.metadata.Table) HiveConf(org.apache.hadoop.hive.conf.HiveConf) QueryState(org.apache.hadoop.hive.ql.QueryState) Before(org.junit.Before)

Example 14 with QueryState

use of org.apache.hadoop.hive.ql.QueryState in project hive by apache.

the class TestSemanticAnalyzerFactory method setup.

@Before
public void setup() throws Exception {
    queryState = new QueryState(null);
    conf = queryState.getConf();
}
Also used : QueryState(org.apache.hadoop.hive.ql.QueryState) Before(org.junit.Before)

Example 15 with QueryState

use of org.apache.hadoop.hive.ql.QueryState in project hive by apache.

the class HiveMaterializedViewsRegistry method parseQuery.

private static RelNode parseQuery(String viewQuery) {
    try {
        final ASTNode node = ParseUtils.parse(viewQuery);
        final QueryState qs = new QueryState(SessionState.get().getConf());
        CalcitePlanner analyzer = new CalcitePlanner(qs);
        analyzer.initCtx(new Context(SessionState.get().getConf()));
        analyzer.init(false);
        return analyzer.genLogicalPlan(node);
    } catch (Exception e) {
        // We could not parse the view
        return null;
    }
}
Also used : Context(org.apache.hadoop.hive.ql.Context) ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) CalcitePlanner(org.apache.hadoop.hive.ql.parse.CalcitePlanner) QueryState(org.apache.hadoop.hive.ql.QueryState) CalciteSemanticException(org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException) SerDeException(org.apache.hadoop.hive.serde2.SerDeException)

Aggregations

QueryState (org.apache.hadoop.hive.ql.QueryState)16 HiveConf (org.apache.hadoop.hive.conf.HiveConf)9 Hive (org.apache.hadoop.hive.ql.metadata.Hive)6 Before (org.junit.Before)6 Table (org.apache.hadoop.hive.ql.metadata.Table)5 ArrayList (java.util.ArrayList)4 Context (org.apache.hadoop.hive.ql.Context)4 BeforeClass (org.junit.BeforeClass)4 Partition (org.apache.hadoop.hive.ql.metadata.Partition)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Path (org.apache.hadoop.fs.Path)2 CompilationOpContext (org.apache.hadoop.hive.ql.CompilationOpContext)2 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 FetchConverter (org.apache.hadoop.hive.common.io.FetchConverter)1 DriverContext (org.apache.hadoop.hive.ql.DriverContext)1 QueryPlan (org.apache.hadoop.hive.ql.QueryPlan)1