SQL 语法风格是指我们查询数据的时候使用 SQL 语句来查询.
    这种风格的查询必须要有临时视图或者全局视图来辅助

    1. scala> val df = spark.read.json("/opt/module/spark-local/examples/src/main/resources/people.json")
    2. df: org.apache.spark.sql.DataFrame = [age: bigint, name: string]
    3. scala> df2.createOrReplaceTempView("people")
    4. scala> spark.sql("select * from people").show
    5. +----+-------+
    6. | age| name|
    7. +----+-------+
    8. |null|Michael|
    9. | 30| Andy|
    10. | 19| Justin|
    11. +----+-------+

    注意:
    1.临时视图只能在当前 Session 有效, 在新的 Session 中无效.
    2.可以创建全局视图. 访问全局视图需要全路径:如global_temp.xxx

    1. scala> val df = spark.read.json("/opt/module/spark-local/examples/src/main/resources/people.json")
    2. df: org.apache.spark.sql.DataFrame = [age: bigint, name: string]
    3. scala> df.createGlobalTempView("people")
    4. scala> spark.sql("select * from global_temp.people")
    5. res31: org.apache.spark.sql.DataFrame = [age: bigint, name: string]
    6. scala> res31.show
    7. +----+-------+
    8. | age| name|
    9. +----+-------+
    10. |null|Michael|
    11. | 30| Andy|
    12. | 19| Justin|
    13. +----+-------+
    14. scala> spark.newSession.sql("select * from global_temp.people")
    15. res33: org.apache.spark.sql.DataFrame = [age: bigint, name: string]
    16. scala> res33.show
    17. +----+-------+
    18. | age| name|
    19. +----+-------+
    20. |null|Michael|
    21. | 30| Andy|
    22. | 19| Justin|
    23. +----+-------+