Search in sources :

Example 1 with ParseDriver

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

the class QTestUtil method init.

public void init() throws Exception {
    // Create remote dirs once.
    if (mr != null) {
        createRemoteDirs();
    }
    testWarehouse = conf.getVar(HiveConf.ConfVars.METASTOREWAREHOUSE);
    String execEngine = conf.get("hive.execution.engine");
    conf.set("hive.execution.engine", "mr");
    SessionState.start(conf);
    conf.set("hive.execution.engine", execEngine);
    db = Hive.get(conf);
    drv = new Driver(conf);
    drv.init();
    pd = new ParseDriver();
    sem = new SemanticAnalyzer(queryState);
}
Also used : ParseDriver(org.apache.hadoop.hive.ql.parse.ParseDriver) ParseDriver(org.apache.hadoop.hive.ql.parse.ParseDriver) CliDriver(org.apache.hadoop.hive.cli.CliDriver) SemanticAnalyzer(org.apache.hadoop.hive.ql.parse.SemanticAnalyzer) BaseSemanticAnalyzer(org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer)

Example 2 with ParseDriver

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

the class HiveTestUtil method init.

public void init() throws Exception {
    testWarehouse = conf.getVar(HiveConf.ConfVars.METASTOREWAREHOUSE);
    conf.setBoolVar(HiveConf.ConfVars.SUBMITLOCALTASKVIACHILD, false);
    String execEngine = conf.get("hive.execution.engine");
    conf.set("hive.execution.engine", "mr");
    SessionState.start(conf);
    conf.set("hive.execution.engine", execEngine);
    db = Hive.get(conf);
    pd = new ParseDriver();
    sem = new SemanticAnalyzer(conf);
}
Also used : ParseDriver(org.apache.hadoop.hive.ql.parse.ParseDriver) SemanticAnalyzer(org.apache.hadoop.hive.ql.parse.SemanticAnalyzer) BaseSemanticAnalyzer(org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer)

Example 3 with ParseDriver

use of org.apache.hadoop.hive.ql.parse.ParseDriver 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 4 with ParseDriver

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

the class QTestUtil method resetParser.

public void resetParser() throws SemanticException {
    drv.init();
    pd = new ParseDriver();
    queryState = new QueryState(conf);
    sem = new SemanticAnalyzer(queryState);
}
Also used : ParseDriver(org.apache.hadoop.hive.ql.parse.ParseDriver) SemanticAnalyzer(org.apache.hadoop.hive.ql.parse.SemanticAnalyzer) BaseSemanticAnalyzer(org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer)

Example 5 with ParseDriver

use of org.apache.hadoop.hive.ql.parse.ParseDriver in project incubator-atlas by apache.

the class HiveASTRewriter method rewrite.

public String rewrite(String sourceQry) throws RewriteException {
    String result = sourceQry;
    ASTNode tree = null;
    try {
        ParseDriver pd = new ParseDriver();
        tree = pd.parse(sourceQry, queryContext, true);
        tree = ParseUtils.findRootNonNullToken(tree);
        this.rwCtx = new RewriteContext(sourceQry, tree, queryContext.getTokenRewriteStream());
        rewrite(tree);
        result = toSQL();
    } catch (ParseException e) {
        LOG.error("Could not parse the query {} ", sourceQry, e);
        throw new RewriteException("Could not parse query : ", e);
    }
    return result;
}
Also used : ASTNode(org.apache.hadoop.hive.ql.parse.ASTNode) ParseDriver(org.apache.hadoop.hive.ql.parse.ParseDriver) ParseException(org.apache.hadoop.hive.ql.parse.ParseException)

Aggregations

ParseDriver (org.apache.hadoop.hive.ql.parse.ParseDriver)6 BaseSemanticAnalyzer (org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer)4 SemanticAnalyzer (org.apache.hadoop.hive.ql.parse.SemanticAnalyzer)4 CliDriver (org.apache.hadoop.hive.cli.CliDriver)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 Context (org.apache.hadoop.hive.ql.Context)1 QueryState (org.apache.hadoop.hive.ql.QueryState)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 ASTNode (org.apache.hadoop.hive.ql.parse.ASTNode)1 DDLSemanticAnalyzer (org.apache.hadoop.hive.ql.parse.DDLSemanticAnalyzer)1 ParseException (org.apache.hadoop.hive.ql.parse.ParseException)1 HadoopDefaultAuthenticator (org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator)1 Before (org.junit.Before)1