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

    https://github.com/apache/spark/pull/14119#discussion_r70262914
  
    --- Diff: docs/sql-programming-guide.md ---
    @@ -679,43 +435,7 @@ a `DataFrame` can be created programmatically with 
three steps.
     by `SparkSession`.
     
     For example:
    -{% highlight scala %}
    -val spark: SparkSession // An existing SparkSession
    -
    -// Create an RDD
    -val people = sc.textFile("examples/src/main/resources/people.txt")
    -
    -// The schema is encoded in a string
    -val schemaString = "name age"
    -
    -// Import Row.
    -import org.apache.spark.sql.Row;
    -
    -// Import Spark SQL data types
    -import org.apache.spark.sql.types.{StructType, StructField, StringType};
    -
    -// Generate the schema based on the string of schema
    -val schema = StructType(schemaString.split(" ").map { fieldName =>
    -  StructField(fieldName, StringType, true)
    -})
    -
    -// Convert records of the RDD (people) to Rows.
    -val rowRDD = people.map(_.split(",")).map(p => Row(p(0), p(1).trim))
    -
    -// Apply the schema to the RDD.
    -val peopleDataFrame = spark.createDataFrame(rowRDD, schema)
    -
    -// Creates a temporary view using the DataFrame.
    -peopleDataFrame.createOrReplaceTempView("people")
    -
    -// SQL statements can be run by using the sql methods provided by spark.
    -val results = spark.sql("SELECT name FROM people")
    -
    -// The columns of a row in the result can be accessed by field index or by 
field name.
    -results.map(t => "Name: " + t(0)).collect().foreach(println)
    -{% endhighlight %}
    -
    -
    +{% include_example programmatic_schema 
scala/org/apache/spark/examples/sql/SparkSqlExample.scala %}
    --- End diff --
    
    Seems that you have to add a newline before the `{% include_example ... %}` 
tag, otherwise this section can't be properly rendered, not sure why:
    
    <img width="925" alt="screenshot at jul 11 21-59-30" 
src="https://cloud.githubusercontent.com/assets/230655/16733123/cd5a0d70-47b2-11e6-9689-621e9bdac73f.png";>



---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to