Permalink
Browse files

HIVE-1415: add CLI command for executing a SQL script

(Edward Capriolo via jvs)



git-svn-id: https://svn.apache.org/repos/asf/hive/trunk@1043849 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 6cef02e commit 0aecd37fea172b6e636b6623daef71c56327ee1f John Sichi committed Dec 9, 2010
View
@@ -300,6 +300,9 @@ Trunk - Unreleased
HIVE-1834 more debugging for locking
(namit via He Yongqiang)
+ HIVE-1415: add CLI command for executing a SQL script
+ (Edward Capriolo via jvs)
+
OPTIMIZATIONS
BUG FIXES
@@ -89,6 +89,20 @@ public int processCmd(String cmd) {
// this counts as a successful run
System.exit(0);
+ } else if (tokens[0].equalsIgnoreCase("source")) {
+ File sourceFile = new File(cmd_1);
+ if (! sourceFile.isFile()){
+ console.printError("File: "+ cmd_1 + " is not a file.");
+ ret = 1;
+ } else {
+ try {
+ this.processFile(cmd_1);
+ } catch (IOException e) {
+ console.printError("Failed processing file "+ cmd_1 +" "+ e.getLocalizedMessage(),
+ org.apache.hadoop.util.StringUtils.stringifyException(e));
+ ret = 1;
+ }
+ }
} else if (cmd_trimmed.startsWith("!")) {
String shell_cmd = cmd_trimmed.substring(1);
View
@@ -0,0 +1,4 @@
+EXPLAIN
+SELECT x.* FROM SRC x;
+
+SELECT x.* FROM SRC x;
@@ -143,6 +143,11 @@ Use ";" (semicolon) to terminate commands. Comments in scripts can be specified
<td>Executes a hive query and prints results to standard out</td>
</tr>
+<tr>
+<td>source FILE</td>
+<td>Used to execute a script file inside the CLI.</td>
+</tr>
+
</table>
Sample Usage:
@@ -0,0 +1 @@
+source ../data/files/source.txt;
Oops, something went wrong.

0 comments on commit 0aecd37

Please sign in to comment.