How to execute multi line sql in spark sql

后端 未结 5 608
余生分开走
余生分开走 2020-12-29 12:20

How can I execute lengthy, multiline Hive Queries in Spark SQL? Like query below:

val sqlContext = new HiveContext (sc)
val result = sqlContext.sql (\"
 sele         


        
5条回答
  •  隐瞒了意图╮
    2020-12-29 12:40

    Use """ instead, so for example

    val results = sqlContext.sql ("""
         select ....
         from ....
    """);
    

    or, if you want to format code, use:

    val results = sqlContext.sql ("""
         |select ....
         |from ....
    """.stripMargin);
    

提交回复
热议问题