Package org.apache.hadoop.hive.ql

Examples of org.apache.hadoop.hive.ql.Driver


    } else {
      CommandProcessor proc = CommandProcessorFactory.get(tokens[0]);
      if (proc != null) {
        if (proc instanceof Driver) {
          Driver qp = (Driver) proc;
          PrintStream out = ss.out;
          long start = System.currentTimeMillis();

          ret = qp.run(cmd).getResponseCode();
          if (ret != 0) {
            qp.close();
            return ret;
          }

          ArrayList<String> res = new ArrayList<String>();
          try {
            while (qp.getResults(res)) {
              for (String r : res) {
                out.println(r);
              }
              res.clear();
              if (out.checkError()) {
                break;
              }
            }
          } catch (IOException e) {
            console.printError("Failed with exception " + e.getClass().getName() + ":"
                + e.getMessage(), "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
            ret = 1;
          }

          int cret = qp.close();
          if (ret == 0) {
            ret = cret;
          }

          long end = System.currentTimeMillis();
View Full Code Here


      }

      SessionState.start(ss);

      String cmd = "select a.key from src a";
      Driver d = new Driver();
      int ret = d.run(cmd);
      if (ret != 0) {
        fail("Failed");
      }
      HiveHistoryViewer hv = new HiveHistoryViewer(SessionState.get()
          .getHiveHistory().getHistFileName());
View Full Code Here

    SessionState.initHiveLog4j();
    conf = new HiveConf(SessionState.class);
    ss = new CliSessionState(conf);
    SessionState.start(ss);
    sp = new SetProcessor();
    qp = new Driver();

    runSetProcessorQuery("hadoop.job.ugi=" + auth.getUser() + ","
        + auth.getGroups()[0]);
    runSetProcessorQuery("user.name=" + auth.getUser());
    /*
 
View Full Code Here

    } else if (cmdl.equals("add")) {
      return new AddResourceProcessor();
    } else if (cmdl.equals("delete")) {
      return new DeleteResourceProcessor();
    } else if (!StringUtils.isBlank(cmd)) {
      return new Driver();
    }
    return null;
  }
View Full Code Here

      SessionState session = new SessionState(new HiveConf(SessionState.class));
      SessionState.start(session);
      session.in = null;
      session.out = null;
      session.err = null;
      driver = new Driver();
    }
View Full Code Here

    } else {
      CommandProcessor proc = CommandProcessorFactory.get(tokens[0]);
      if(proc != null) {
        if(proc instanceof Driver) {
          Driver qp = (Driver) proc;
          PrintStream out = ss.out;
          long start = System.currentTimeMillis();

          ret = qp.run(cmd);
          if (ret != 0) {
            qp.close();
            return ret;
          }
       
          Vector<String> res = new Vector<String>();
          try {
            while (qp.getResults(res)) {
              for (String r:res) {
                out.println(r);
              }
              res.clear();
              if (out.checkError()) {
                break;
              }
            }
          } catch (IOException e) {
            console.printError("Failed with exception " + e.getClass().getName() + ":" +   e.getMessage(),
                "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
            ret = 1;
          }
           
          int cret = qp.close();
          if (ret == 0) {
            ret = cret;
          }

          long end = System.currentTimeMillis();
View Full Code Here

    // We want the driver to try to print the header...
    Configuration conf = mock(Configuration.class);
    when(conf.getBoolean(eq(ConfVars.HIVE_CLI_PRINT_HEADER.varname), anyBoolean())).thenReturn(true);
    cliDriver.setConf(conf);

    Driver proc = mock(Driver.class);

    CommandProcessorResponse cpr = mock(CommandProcessorResponse.class);
    when(cpr.getResponseCode()).thenReturn(0);
    when(proc.run(anyString())).thenReturn(cpr);

    // and then see what happens based on the provided schema
    when(proc.getSchema()).thenReturn(mockSchema);

    CliSessionState mockSS = mock(CliSessionState.class);
    PrintStream mockOut = mock(PrintStream.class);

    mockSS.out = mockOut;
View Full Code Here

    hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
    hiveConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
    hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
    SessionState.start(new CliSessionState(hiveConf));
    msc = new HiveMetaStoreClient(hiveConf, null);
    driver = new Driver(hiveConf);
  }
View Full Code Here

  public void testMarkingPartitionSet() throws CommandNeedRetryException, MetaException,
  TException, NoSuchObjectException, UnknownDBException, UnknownTableException,
  InvalidPartitionException, UnknownPartitionException, InterruptedException {
    HiveMetaStoreClient msc = new HiveMetaStoreClient(hiveConf, null);
    driver = new Driver(hiveConf);
    driver.run("drop database if exists tmpdb cascade");
    driver.run("create database tmpdb");
    driver.run("use tmpdb");
    driver.run("drop table if exists tmptbl");
    driver.run("create table tmptbl (a string) partitioned by (b string)");
View Full Code Here

    do {
      try {
        needRetry = false;
        if (proc != null) {
          if (proc instanceof Driver) {
            Driver qp = (Driver) proc;
            PrintStream out = ss.out;
            long start = System.currentTimeMillis();
            if (ss.getIsVerbose()) {
              out.println(cmd);
            }

            qp.setTryCount(tryCount);
            ret = qp.run(cmd).getResponseCode();
            if (ret != 0) {
              qp.close();
              return ret;
            }

            ArrayList<String> res = new ArrayList<String>();

            printHeader(qp, out);

            try {
              while (qp.getResults(res)) {
                for (String r : res) {
                  out.println(r);
                }
                res.clear();
                if (out.checkError()) {
                  break;
                }
              }
            } catch (IOException e) {
              console.printError("Failed with exception " + e.getClass().getName() + ":"
                  + e.getMessage(), "\n"
                  + org.apache.hadoop.util.StringUtils.stringifyException(e));
              ret = 1;
            }

            int cret = qp.close();
            if (ret == 0) {
              ret = cret;
            }

            long end = System.currentTimeMillis();
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.Driver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.