Search in sources :

Example 1 with DDLSemanticAnalyzer

use of org.apache.hadoop.hive.ql.parse.DDLSemanticAnalyzer in project hive by apache.

the class AuthorizationTestUtil method analyze.

/**
   * Create DDLWork from given ast
   * @param ast
   * @param conf
   * @param db
   * @return
   * @throws Exception
   */
public static DDLWork analyze(ASTNode ast, QueryState queryState, Hive db) throws Exception {
    DDLSemanticAnalyzer analyzer = new DDLSemanticAnalyzer(queryState, db);
    SessionState.start(queryState.getConf());
    analyzer.analyze(ast, new Context(queryState.getConf()));
    List<Task<? extends Serializable>> rootTasks = analyzer.getRootTasks();
    return (DDLWork) inList(rootTasks).ofSize(1).get(0).getWork();
}
Also used : Context(org.apache.hadoop.hive.ql.Context) Task(org.apache.hadoop.hive.ql.exec.Task) Serializable(java.io.Serializable) DDLWork(org.apache.hadoop.hive.ql.plan.DDLWork) DDLSemanticAnalyzer(org.apache.hadoop.hive.ql.parse.DDLSemanticAnalyzer)

Example 2 with DDLSemanticAnalyzer

use of org.apache.hadoop.hive.ql.parse.DDLSemanticAnalyzer 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)

Aggregations

Context (org.apache.hadoop.hive.ql.Context)2 DDLSemanticAnalyzer (org.apache.hadoop.hive.ql.parse.DDLSemanticAnalyzer)2 Serializable (java.io.Serializable)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 QueryState (org.apache.hadoop.hive.ql.QueryState)1 Task (org.apache.hadoop.hive.ql.exec.Task)1 Hive (org.apache.hadoop.hive.ql.metadata.Hive)1 Partition (org.apache.hadoop.hive.ql.metadata.Partition)1 Table (org.apache.hadoop.hive.ql.metadata.Table)1 ParseDriver (org.apache.hadoop.hive.ql.parse.ParseDriver)1 DDLWork (org.apache.hadoop.hive.ql.plan.DDLWork)1 HadoopDefaultAuthenticator (org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator)1 Before (org.junit.Before)1