Search in sources :

Example 6 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project hive by apache.

the class TestTxnCommands method setUp.

@Before
public void setUp() throws Exception {
    tearDown();
    hiveConf = new HiveConf(this.getClass());
    hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
    hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
    hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
    hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, TEST_WAREHOUSE_DIR);
    hiveConf.setVar(HiveConf.ConfVars.HIVEMAPREDMODE, "nonstrict");
    hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    hiveConf.setBoolVar(HiveConf.ConfVars.MERGE_CARDINALITY_VIOLATION_CHECK, true);
    TxnDbUtil.setConfValues(hiveConf);
    TxnDbUtil.prepDb();
    File f = new File(TEST_WAREHOUSE_DIR);
    if (f.exists()) {
        FileUtil.fullyDelete(f);
    }
    if (!(new File(TEST_WAREHOUSE_DIR).mkdirs())) {
        throw new RuntimeException("Could not create " + TEST_WAREHOUSE_DIR);
    }
    SessionState.start(new SessionState(hiveConf));
    d = new Driver(hiveConf);
    d.setMaxRows(10000);
    dropTables();
    runStatementOnDriver("create table " + Table.ACIDTBL + "(a int, b int) clustered by (a) into " + BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES ('transactional'='true')");
    runStatementOnDriver("create table " + Table.ACIDTBLPART + "(a int, b int) partitioned by (p string) clustered by (a) into " + BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES ('transactional'='true')");
    runStatementOnDriver("create table " + Table.NONACIDORCTBL + "(a int, b int) clustered by (a) into " + BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES ('transactional'='false')");
    runStatementOnDriver("create table " + Table.NONACIDORCTBL2 + "(a int, b int) clustered by (a) into " + BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES ('transactional'='false')");
    runStatementOnDriver("create temporary  table " + Table.ACIDTBL2 + "(a int, b int, c int) clustered by (c) into " + BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES ('transactional'='true')");
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveConf(org.apache.hadoop.hive.conf.HiveConf) File(java.io.File) Before(org.junit.Before)

Example 7 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project hive by apache.

the class TestTxnCommands2 method setUpWithTableProperties.

protected void setUpWithTableProperties(String tableProperties) throws Exception {
    tearDown();
    hiveConf = new HiveConf(this.getClass());
    hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
    hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
    hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
    hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, TEST_WAREHOUSE_DIR);
    hiveConf.setVar(HiveConf.ConfVars.HIVEMAPREDMODE, "nonstrict");
    hiveConf.setVar(HiveConf.ConfVars.HIVEINPUTFORMAT, HiveInputFormat.class.getName());
    hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
    hiveConf.setBoolVar(HiveConf.ConfVars.MERGE_CARDINALITY_VIOLATION_CHECK, true);
    TxnDbUtil.setConfValues(hiveConf);
    TxnDbUtil.prepDb();
    File f = new File(TEST_WAREHOUSE_DIR);
    if (f.exists()) {
        FileUtil.fullyDelete(f);
    }
    if (!(new File(TEST_WAREHOUSE_DIR).mkdirs())) {
        throw new RuntimeException("Could not create " + TEST_WAREHOUSE_DIR);
    }
    SessionState.start(new SessionState(hiveConf));
    d = new Driver(hiveConf);
    d.setMaxRows(10000);
    dropTables();
    runStatementOnDriver("create table " + Table.ACIDTBL + "(a int, b int) clustered by (a) into " + BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES (" + tableProperties + ")");
    runStatementOnDriver("create table " + Table.ACIDTBLPART + "(a int, b int) partitioned by (p string) clustered by (a) into " + BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES (" + tableProperties + ")");
    runStatementOnDriver("create table " + Table.NONACIDORCTBL + "(a int, b int) clustered by (a) into " + BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES ('transactional'='false')");
    runStatementOnDriver("create table " + Table.NONACIDPART + "(a int, b int) partitioned by (p string) stored as orc TBLPROPERTIES ('transactional'='false')");
    runStatementOnDriver("create table " + Table.NONACIDPART2 + "(a2 int, b2 int) partitioned by (p2 string) stored as orc TBLPROPERTIES ('transactional'='false')");
    runStatementOnDriver("create table " + Table.ACIDNESTEDPART + "(a int, b int) partitioned by (p int, q int) clustered by (a) into " + BUCKET_COUNT + " buckets stored as orc TBLPROPERTIES (" + tableProperties + ")");
}
Also used : HiveInputFormat(org.apache.hadoop.hive.ql.io.HiveInputFormat) SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveConf(org.apache.hadoop.hive.conf.HiveConf) File(java.io.File)

Example 8 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project hive by apache.

the class TestSessionUserName method testSessionDefaultUser.

/**
   * Test if the authorization factory gets the username provided by
   * the authenticator, if SesstionState is created without username
   * @throws Exception
   */
@Test
public void testSessionDefaultUser() throws Exception {
    SessionState ss = new SessionState(getAuthV2HiveConf());
    setupDataNucleusFreeHive(ss.getConf());
    SessionState.start(ss);
    Assert.assertEquals("check username", ss.getAuthenticator().getUserName(), HiveAuthorizerStoringUserNameFactory.username);
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) Test(org.junit.Test)

Example 9 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project hive by apache.

the class SQLOperation method cleanup.

private synchronized void cleanup(OperationState state) throws HiveSQLException {
    setState(state);
    if (shouldRunAsync()) {
        Future<?> backgroundHandle = getBackgroundHandle();
        if (backgroundHandle != null) {
            boolean success = backgroundHandle.cancel(true);
            if (success) {
                LOG.info("The running operation has been successfully interrupted.");
            }
        }
    }
    if (driver != null) {
        driver.close();
        driver.destroy();
    }
    driver = null;
    SessionState ss = SessionState.get();
    if (ss == null) {
        LOG.warn("Operation seems to be in invalid state, SessionState is null");
    } else {
        ss.deleteTmpOutputFile();
        ss.deleteTmpErrOutputFile();
    }
    // Shutdown the timeout thread if any, while closing this operation
    if ((timeoutExecutor != null) && (state != OperationState.TIMEDOUT) && (state.isTerminal())) {
        timeoutExecutor.shutdownNow();
    }
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState)

Example 10 with SessionState

use of org.apache.hadoop.hive.ql.session.SessionState in project hive by apache.

the class TestHiveHistory method testHiveHistoryConfigDisabled.

/**
   * Check if HiveHistory class is a Proxy class when hive history is disabled
   * @throws Exception
   */
public void testHiveHistoryConfigDisabled() throws Exception {
    HiveConf conf = new HiveConf(SessionState.class);
    conf.setBoolVar(ConfVars.HIVE_SESSION_HISTORY_ENABLED, false);
    SessionState ss = new CliSessionState(conf);
    SessionState.start(ss);
    HiveHistory hHistory = ss.getHiveHistory();
    assertTrue("checking hive history class when history is disabled", hHistory.getClass() != HiveHistoryImpl.class);
    System.err.println("hHistory.getClass" + hHistory.getClass());
    assertTrue("verifying proxy class is used when history is disabled", Proxy.isProxyClass(hHistory.getClass()));
}
Also used : CliSessionState(org.apache.hadoop.hive.cli.CliSessionState) SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveConf(org.apache.hadoop.hive.conf.HiveConf) CliSessionState(org.apache.hadoop.hive.cli.CliSessionState)

Aggregations

SessionState (org.apache.hadoop.hive.ql.session.SessionState)96 IOException (java.io.IOException)24 HiveConf (org.apache.hadoop.hive.conf.HiveConf)19 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)13 ArrayList (java.util.ArrayList)12 LinkedList (java.util.LinkedList)11 Path (org.apache.hadoop.fs.Path)11 CliSessionState (org.apache.hadoop.hive.cli.CliSessionState)11 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)10 File (java.io.File)9 FileNotFoundException (java.io.FileNotFoundException)9 Map (java.util.Map)8 Test (org.junit.Test)8 PrintStream (java.io.PrintStream)7 ExecutionException (java.util.concurrent.ExecutionException)6 FileStatus (org.apache.hadoop.fs.FileStatus)6 URI (java.net.URI)5 FileSystem (org.apache.hadoop.fs.FileSystem)5 Driver (org.apache.hadoop.hive.ql.Driver)5 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)5