diff options
author | scwf <wangfei1@huawei.com> | 2014-11-24 12:49:08 -0800 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2014-11-24 12:49:31 -0800 |
commit | 0e7fa7f632ebe4db60938f2087c1f1a4d614ab32 (patch) | |
tree | 9dd882e0b8bb76c7a8bd862d181ea7aee99b2638 | |
parent | 1e3d22b9fd2c0a87330283c5097b2b7ec95a5715 (diff) | |
download | spark-0e7fa7f632ebe4db60938f2087c1f1a4d614ab32.tar.gz spark-0e7fa7f632ebe4db60938f2087c1f1a4d614ab32.tar.bz2 spark-0e7fa7f632ebe4db60938f2087c1f1a4d614ab32.zip |
[SQL] Fix path in HiveFromSpark
It require us to run ```HiveFromSpark``` in specified dir because ```HiveFromSpark``` use relative path, this leads to ```run-example``` error(http://apache-spark-developers-list.1001551.n3.nabble.com/src-main-resources-kv1-txt-not-found-in-example-of-HiveFromSpark-td9100.html).
Author: scwf <wangfei1@huawei.com>
Closes #3415 from scwf/HiveFromSpark and squashes the following commits:
ed3d6c9 [scwf] revert no need change
b00e20c [scwf] fix path usring spark_home
dbd321b [scwf] fix path in hivefromspark
(cherry picked from commit b384119304617459592b7ba435368dd6fcc3273e)
Signed-off-by: Michael Armbrust <michael@databricks.com>
-rw-r--r-- | examples/src/main/scala/org/apache/spark/examples/sql/hive/HiveFromSpark.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/src/main/scala/org/apache/spark/examples/sql/hive/HiveFromSpark.scala b/examples/src/main/scala/org/apache/spark/examples/sql/hive/HiveFromSpark.scala index 0c52ef8ed9..227acc1175 100644 --- a/examples/src/main/scala/org/apache/spark/examples/sql/hive/HiveFromSpark.scala +++ b/examples/src/main/scala/org/apache/spark/examples/sql/hive/HiveFromSpark.scala @@ -27,6 +27,7 @@ object HiveFromSpark { def main(args: Array[String]) { val sparkConf = new SparkConf().setAppName("HiveFromSpark") val sc = new SparkContext(sparkConf) + val path = s"${System.getenv("SPARK_HOME")}/examples/src/main/resources/kv1.txt" // A local hive context creates an instance of the Hive Metastore in process, storing // the warehouse data in the current directory. This location can be overridden by @@ -35,7 +36,7 @@ object HiveFromSpark { import hiveContext._ sql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING)") - sql("LOAD DATA LOCAL INPATH 'src/main/resources/kv1.txt' INTO TABLE src") + sql(s"LOAD DATA LOCAL INPATH '$path' INTO TABLE src") // Queries are expressed in HiveQL println("Result of 'SELECT *': ") |