You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by kg...@apache.org on 2019/04/02 09:16:48 UTC
[hive] 02/02: HIVE-21511: beeline -f report no such file if file is
not on local fs (Bruno Pusztahazi via Zoltan Haindrich)
This is an automated email from the ASF dual-hosted git repository.
kgyrtkirk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
commit adbf0036ced5197bd4417cb04c9763db7c3ed153
Author: Bruno Pusztahazi <bp...@hortonworks.com>
AuthorDate: Tue Apr 2 11:05:37 2019 +0200
HIVE-21511: beeline -f report no such file if file is not on local fs (Bruno Pusztahazi via Zoltan Haindrich)
Signed-off-by: Zoltan Haindrich <ki...@rxd.hu>
---
beeline/src/java/org/apache/hive/beeline/BeeLine.java | 11 ++++++++++-
.../org/apache/hive/beeline/TestBeelineArgParsing.java | 15 +++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
index 82077cc..65ec560 100644
--- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java
+++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java
@@ -1324,7 +1324,16 @@ public class BeeLine implements Closeable {
}
fileStream = fs.open(path);
} else {
- fileStream = new FileInputStream(fileName);
+ org.apache.hadoop.fs.Path path = new org.apache.hadoop.fs.Path(fileName);
+ FileSystem fs;
+ HiveConf conf = new HiveConf();
+ if (!path.toUri().isAbsolute()) {
+ fs = FileSystem.getLocal(conf);
+ path = fs.makeQualified(path);
+ } else {
+ fs = FileSystem.get(path.toUri(), conf);
+ }
+ fileStream = fs.open(path);
}
return execute(initializeConsoleReader(fileStream), !getOpts().getForce());
} catch (Throwable t) {
diff --git a/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java b/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
index 1fa6a75..c9ff066 100644
--- a/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
+++ b/beeline/src/test/org/apache/hive/beeline/TestBeelineArgParsing.java
@@ -353,4 +353,19 @@ public class TestBeelineArgParsing {
Assert.assertTrue(bl.getOpts().getMaxHistoryRows() == 100);
bl.close();
}
+
+ /**
+ * Test the file parameter option
+ * @throws Exception
+ */
+ @Test
+ public void testFileParam() throws Exception {
+ TestBeeline bl = new TestBeeline();
+ String args[] = new String[] {"-u", "url", "-n", "name",
+ "-p", "password", "-d", "driver", "-f", "hdfs://myscript"};
+ Assert.assertEquals(0, bl.initArgs(args));
+ Assert.assertTrue(bl.connectArgs.equals("url name password driver"));
+ Assert.assertTrue(bl.getOpts().getScriptFile().equals("hdfs://myscript"));
+ }
+
}