Index: cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
===================================================================
--- cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java (revision 1522780)
+++ cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java (working copy)
@@ -432,6 +432,7 @@
}
}
+
public int processReader(BufferedReader r) throws IOException {
String line;
StringBuilder qsb = new StringBuilder();
@@ -767,31 +768,63 @@
int ret = 0;
- String prefix = "";
String curDB = getFormattedDb(conf, ss);
String curPrompt = prompt + curDB;
String dbSpaces = spacesForString(curDB);
+ boolean insideBacktick = false;
+ StringBuilder full = new StringBuilder();
while ((line = reader.readLine(curPrompt + "> ")) != null) {
- if (!prefix.equals("")) {
- prefix += '\n';
+ for (int i = 0; i < line.length(); i++) {
+ char c = line.charAt(i);
+ if (c == "`".charAt(0)){
+ full.append(c);
+ if (!insideBacktick){
+ insideBacktick = true;
+ } else {
+ insideBacktick = false;
+ }
+ } else if (c == "\\".charAt(0)){
+ char n = line.charAt(i+1);
+ full.append(n);
+ i+=1;
+ continue;
+ } else if (c == ';' && (!insideBacktick)) {
+ ret = cli.processLine(full.toString(), true);
+ full = new StringBuilder();
+ curDB = getFormattedDb(conf, ss);
+ curPrompt = prompt + curDB;
+ dbSpaces = dbSpaces.length() == curDB.length() ? dbSpaces : spacesForString(curDB);
+ continue;
+ } else {
+ curPrompt = prompt2 + dbSpaces;
+ full.append(c);
+ }
}
- if (line.trim().endsWith(";") && !line.trim().endsWith("\\;")) {
- line = prefix + line;
- ret = cli.processLine(line, true);
- prefix = "";
- curDB = getFormattedDb(conf, ss);
- curPrompt = prompt + curDB;
- dbSpaces = dbSpaces.length() == curDB.length() ? dbSpaces : spacesForString(curDB);
- } else {
- prefix = prefix + line;
- curPrompt = prompt2 + dbSpaces;
- continue;
- }
}
return ret;
}
+
+
+ /*
+ if (!prefix.equals("")) {
+ prefix += '\n';
+ }
+ if (line.trim().endsWith(";") && !line.trim().endsWith("\\;")) {
+ line = prefix + line;
+ ret = cli.processLine(line, true);
+ prefix = "";
+ curDB = getFormattedDb(conf, ss);
+ curPrompt = prompt + curDB;
+ dbSpaces = dbSpaces.length() == curDB.length() ? dbSpaces : spacesForString(curDB);
+ } else {
+ prefix = prefix + line;
+ curPrompt = prompt2 + dbSpaces;
+ continue;
+ }
+ */
+
protected ConsoleReader getConsoleReader() throws IOException{
return new ConsoleReader();
}
Index: cli/src/test/org/apache/hadoop/hive/cli/TestCliDriverMethods.java
===================================================================
--- cli/src/test/org/apache/hadoop/hive/cli/TestCliDriverMethods.java (revision 1522780)
+++ cli/src/test/org/apache/hadoop/hive/cli/TestCliDriverMethods.java (working copy)
@@ -185,6 +185,18 @@
}
/**
+ * Test compile some groovy
+ */
+ public void testCompile() throws Exception {
+ CliSessionState ss = new CliSessionState(new HiveConf());
+ ss.err = System.err;
+ ss.out = System.out;
+ CliSessionState.start(ss);
+ CliDriver cliDriver = new CliDriver();
+ cliDriver.processCmd("compile ` public class x { \n }` AS GROOVY NAMED x.groovy");
+ }
+
+ /**
* Test commands exit and quit
*/
public void testQuit() throws Exception {
Index: ivy/libraries.properties
===================================================================
--- ivy/libraries.properties (revision 1522780)
+++ ivy/libraries.properties (working copy)
@@ -42,6 +42,7 @@
commons-pool.version=1.5.4
derby.version=10.4.2.0
guava.version=11.0.2
+groovy.version=2.1.6
hbase.version=0.94.6.1
jackson.version=1.8.8
javaewah.version=0.3.2
Index: ql/ivy.xml
===================================================================
--- ql/ivy.xml (revision 1522780)
+++ ql/ivy.xml (working copy)
@@ -49,6 +49,12 @@
+
+
+
+