Github user aokolnychyi commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14119#discussion_r70173058
  
    --- Diff: 
examples/src/main/scala/org/apache/spark/examples/sql/hive/SparkHiveExample.scala
 ---
    @@ -41,43 +35,47 @@ object HiveFromSpark {
         // in the current directory and creates a directory configured by 
`spark.sql.warehouse.dir`,
         // which defaults to the directory `spark-warehouse` in the current 
directory that the spark
         // application is started.
    -    val spark = SparkSession.builder
    -      .appName("HiveFromSpark")
    -      .enableHiveSupport()
    -      .getOrCreate()
    +
    +    // $example on:spark_hive$
    +    // warehouseLocation points to the default location for managed 
databases and tables
    +    val warehouseLocation = "file:${system:user.dir}/spark-warehouse"
    +
    +    val spark = SparkSession
    +        .builder()
    +        .appName("Spark Hive Example")
    +        .config("spark.sql.warehouse.dir", warehouseLocation)
    +        .enableHiveSupport()
    +        .getOrCreate()
     
         import spark.implicits._
         import spark.sql
     
         sql("CREATE TABLE IF NOT EXISTS src (key INT, value STRING)")
    -    sql(s"LOAD DATA LOCAL INPATH '${kv1File.getAbsolutePath}' INTO TABLE 
src")
    +    sql("LOAD DATA LOCAL INPATH 'examples/src/main/resources/kv1.txt' INTO 
TABLE src")
     
         // Queries are expressed in HiveQL
    -    println("Result of 'SELECT *': ")
    -    sql("SELECT * FROM src").collect().foreach(println)
    +    sql("SELECT * FROM src").show()
    --- End diff --
    
    I replaced collect().foreach(println) with show() in all examples. Is it OK?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to