Review Board 1.7.22


HIVE-5441: Async query execution doesn't return resultset status

Review Request #14486 - Created Oct. 4, 2013 and updated

Prasad Mujumdar
trunk
HIVE-5441
Reviewers
hive
hive-git
Separate out the query compilation and execute that part synchronously.
Added test cases
ql/src/java/org/apache/hadoop/hive/ql/Driver.java
Revision c09ffde New Change
[20] 898 lines
[+20] [+] private void releaseLocks(List<HiveLock> hiveLocks) {
899
    ctx.setHiveLocks(null);
899
    ctx.setHiveLocks(null);
900

    
   
900

   
901
    perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.RELEASE_LOCKS);
901
    perfLogger.PerfLogEnd(CLASS_NAME, PerfLogger.RELEASE_LOCKS);
902
  }
902
  }
903

    
   
903

   
904
  public CommandProcessorResponse run(String command) throws CommandNeedRetryException {
904
  public CommandProcessorResponse run(String command)
905
    CommandProcessorResponse cpr = runInternal(command);
905
      throws CommandNeedRetryException {

    
   
906
    return run(command, false);

    
   
907
  }

    
   
908

   

    
   
909
  public CommandProcessorResponse run()

    
   
910
      throws CommandNeedRetryException {

    
   
911
    return run(null, true);

    
   
912
  }

    
   
913

   

    
   
914
  public CommandProcessorResponse run(String command, boolean alreadyCompiled)

    
   
915
        throws CommandNeedRetryException {

    
   
916
    CommandProcessorResponse cpr = runInternal(command, alreadyCompiled);
906
    if(cpr.getResponseCode() == 0) {
917
    if(cpr.getResponseCode() == 0) {
907
      return cpr;
918
      return cpr;
908
    }
919
    }
909
    SessionState ss = SessionState.get();
920
    SessionState ss = SessionState.get();
910
    if(ss == null) {
921
    if(ss == null) {
[+20] [20] 44 lines
[+20] public CommandProcessorResponse run(String command) throws CommandNeedRetryException { [+] public CommandProcessorResponse run(String command, boolean alreadyCompiled)
955
      console.printError("Unable to JSON-encode the error",
966
      console.printError("Unable to JSON-encode the error",
956
              org.apache.hadoop.util.StringUtils.stringifyException(ex));
967
              org.apache.hadoop.util.StringUtils.stringifyException(ex));
957
    }
968
    }
958
    return cpr;
969
    return cpr;
959
  }
970
  }
960
  private CommandProcessorResponse runInternal(String command) throws CommandNeedRetryException {
971

   

    
   
972
  public CommandProcessorResponse compileAndRespond(String command) {

    
   
973
    return new CommandProcessorResponse(compileInternal(command),

    
   
974
        errorMessage, SQLState);

    
   
975
  }

    
   
976

   

    
   
977
  private int compileInternal(String command) {

    
   
978
    int ret;

    
   
979
    synchronized (compileMonitor) {

    
   
980
      ret = compile(command);

    
   
981
    }

    
   
982
    if (ret != 0) {

    
   
983
      releaseLocks(ctx.getHiveLocks());

    
   
984
    }

    
   
985
    return ret;

    
   
986
  }

    
   
987

   

    
   
988
  private CommandProcessorResponse runInternal(String command, boolean alreadyCompiled)

    
   
989
      throws CommandNeedRetryException {
961
    errorMessage = null;
990
    errorMessage = null;
962
    SQLState = null;
991
    SQLState = null;
963
    downstreamError = null;
992
    downstreamError = null;
964

    
   
993

   
965
    if (!validateConfVariables()) {
994
    if (!validateConfVariables()) {
[+20] [20] 22 lines
[+20] private CommandProcessorResponse runInternal(String command) throws CommandNeedRetryException { [+] private CommandProcessorResponse runInternal(String command, boolean alreadyCompiled)
988
    PerfLogger perfLogger = PerfLogger.getPerfLogger(true);
1017
    PerfLogger perfLogger = PerfLogger.getPerfLogger(true);
989
    perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.DRIVER_RUN);
1018
    perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.DRIVER_RUN);
990
    perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.TIME_TO_SUBMIT);
1019
    perfLogger.PerfLogBegin(CLASS_NAME, PerfLogger.TIME_TO_SUBMIT);
991

    
   
1020

   
992
    int ret;
1021
    int ret;
993
    synchronized (compileMonitor) {
1022
    if (!alreadyCompiled) {
994
      ret = compile(command);
1023
      ret = compileInternal(command);
995
    }

   
996
    if (ret != 0) {
1024
      if (ret != 0) {
997
      releaseLocks(ctx.getHiveLocks());

   
998
      return new CommandProcessorResponse(ret, errorMessage, SQLState);
1025
        return new CommandProcessorResponse(ret, errorMessage, SQLState);
999
    }
1026
      }

    
   
1027
    }
1000

    
   
1028

   
1001
    boolean requireLock = false;
1029
    boolean requireLock = false;
1002
    boolean ckLock = false;
1030
    boolean ckLock = false;
1003
    try {
1031
    try {
1004
      ckLock = checkConcurrency();
1032
      ckLock = checkConcurrency();
[+20] [20] 607 lines
service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
Revision 4ee1b74 New Change
 
service/src/test/org/apache/hive/service/cli/CLIServiceTest.java
Revision cd9d99a New Change
 
  1. ql/src/java/org/apache/hadoop/hive/ql/Driver.java: Loading...
  2. service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java: Loading...
  3. service/src/test/org/apache/hive/service/cli/CLIServiceTest.java: Loading...