You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by zs...@apache.org on 2008/12/10 23:37:15 UTC

svn commit: r725472 - in /hadoop/hive/trunk: ./ cli/src/java/org/apache/hadoop/hive/cli/ ql/src/test/results/clientnegative/

Author: zshao
Date: Wed Dec 10 14:37:14 2008
New Revision: 725472

URL: http://svn.apache.org/viewvc?rev=725472&view=rev
Log:
HIVE-47. CLI to support multiline queries from an input file. (Ashish through zshao)

Modified:
    hadoop/hive/trunk/CHANGES.txt
    hadoop/hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
    hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbydistributeby.q.out
    hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbysortby.q.out
    hadoop/hive/trunk/ql/src/test/results/clientnegative/notable_alias3.q.out
    hadoop/hive/trunk/ql/src/test/results/clientnegative/strict_pruning.q.out

Modified: hadoop/hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/CHANGES.txt?rev=725472&r1=725471&r2=725472&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Wed Dec 10 14:37:14 2008
@@ -36,6 +36,9 @@
 
   BUG FIXES
 
+    HIVE-47. CLI to support multiline queries from an input file.
+    (Ashish through zshao)
+
     HIVE-103. Disable inserts in sub queries. (Namit Jain through zshao)
 
     HIVE-92. Fixed union all for non-embedded query. (Namit Jain through zshao)

Modified: hadoop/hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java?rev=725472&r1=725471&r2=725472&view=diff
==============================================================================
--- hadoop/hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java (original)
+++ hadoop/hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java Wed Dec 10 14:37:14 2008
@@ -56,25 +56,26 @@
   
   public int processCmd(String cmd) {
     SessionState ss = SessionState.get();
-
-    String[] tokens = cmd.split("\\s+");
-    String cmd_1 = cmd.substring(tokens[0].length());
+    
+    String cmd_trimmed = cmd.trim();
+    String[] tokens = cmd_trimmed.split("\\s+");
+    String cmd_1 = cmd_trimmed.substring(tokens[0].length());
     int ret = 0;
     
     if(tokens[0].toLowerCase().equals("set")) {
 
       ret = sp.run(cmd_1);
 
-    } else if (cmd.toLowerCase().equals("quit") || cmd.toLowerCase().equals("exit")) {
+    } else if (cmd_trimmed.toLowerCase().equals("quit") || cmd_trimmed.toLowerCase().equals("exit")) {
 
       // if we have come this far - either the previous commands
       // are all successful or this is command line. in either case
       // this counts as a successful run
       System.exit(0);
 
-    } else if (cmd.startsWith("!")) {
+    } else if (cmd_trimmed.startsWith("!")) {
 
-      String shell_cmd = cmd.substring(1);
+      String shell_cmd = cmd_trimmed.substring(1);
 
       //shell_cmd = "/bin/bash -c \'" + shell_cmd + "\'";
       try {
@@ -165,7 +166,7 @@
         ss.delete_resource(t);
       }
 
-    } else {
+    } else if (!cmd_trimmed.equals("")) {
       PrintStream out = ss.out;
 
       long start = System.currentTimeMillis();
@@ -197,7 +198,6 @@
   public int processLine(String line) {
     int ret = 0;
     for(String oneCmd: line.split(";")) {
-      oneCmd = oneCmd.trim();
       if(oneCmd.equals(""))
         continue;
       
@@ -212,13 +212,18 @@
 
   public int processReader(BufferedReader r) throws IOException {
     String line;
+    StringBuffer qsb = new StringBuffer();
     int ret = 0;
+
     while((line = r.readLine()) != null) {
-      ret = processLine(line);
-      if(ret != 0) {
-        return ret;
-      }
+      qsb.append(line + "\n");
+    }
+
+    ret = processLine(qsb.toString());
+    if (ret != 0) {
+      return ret;
     }
+
     return 0;
   }
 

Modified: hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbydistributeby.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbydistributeby.q.out?rev=725472&r1=725471&r2=725472&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbydistributeby.q.out (original)
+++ hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbydistributeby.q.out Wed Dec 10 14:37:14 2008
@@ -1 +1 @@
-FAILED: Error in semantic analysis: line 6:14 Cannot have both Cluster By and Distribute By Clauses tkey
+FAILED: Error in semantic analysis: line 8:14 Cannot have both Cluster By and Distribute By Clauses tkey

Modified: hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbysortby.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbysortby.q.out?rev=725472&r1=725471&r2=725472&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbysortby.q.out (original)
+++ hadoop/hive/trunk/ql/src/test/results/clientnegative/clusterbysortby.q.out Wed Dec 10 14:37:14 2008
@@ -1 +1 @@
-FAILED: Error in semantic analysis: line 6:8 Cannot have both Cluster By and Sort By Clauses one
+FAILED: Error in semantic analysis: line 8:8 Cannot have both Cluster By and Sort By Clauses one

Modified: hadoop/hive/trunk/ql/src/test/results/clientnegative/notable_alias3.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientnegative/notable_alias3.q.out?rev=725472&r1=725471&r2=725472&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientnegative/notable_alias3.q.out (original)
+++ hadoop/hive/trunk/ql/src/test/results/clientnegative/notable_alias3.q.out Wed Dec 10 14:37:14 2008
@@ -1 +1 @@
-FAILED: Error in semantic analysis: line 2:44 Expression Not In Group By Key key
+FAILED: Error in semantic analysis: line 4:44 Expression Not In Group By Key key

Modified: hadoop/hive/trunk/ql/src/test/results/clientnegative/strict_pruning.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientnegative/strict_pruning.q.out?rev=725472&r1=725471&r2=725472&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientnegative/strict_pruning.q.out (original)
+++ hadoop/hive/trunk/ql/src/test/results/clientnegative/strict_pruning.q.out Wed Dec 10 14:37:14 2008
@@ -1 +1 @@
-FAILED: Error in semantic analysis: line 2:7 No Partition Predicate Found 1:  for Alias srcpart Table srcpart
+FAILED: Error in semantic analysis: line 4:7 No Partition Predicate Found 1:  for Alias srcpart Table srcpart