aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorscwf <wangfei1@huawei.com>2014-11-24 12:49:08 -0800
committerMichael Armbrust <michael@databricks.com>2014-11-24 12:49:08 -0800
commitb384119304617459592b7ba435368dd6fcc3273e (patch)
tree7b775a2918c8c7b83cfa4c3f7c007c74b642b09b /examples
parentd5834f0732b586731034a7df5402c25454770fc5 (diff)
downloadspark-b384119304617459592b7ba435368dd6fcc3273e.tar.gz
spark-b384119304617459592b7ba435368dd6fcc3273e.tar.bz2
spark-b384119304617459592b7ba435368dd6fcc3273e.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
Diffstat (limited to 'examples')
-rw-r--r--examples/src/main/scala/org/apache/spark/examples/sql/hive/HiveFromSpark.scala3
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 *': ")