spark query: unclosed character literal

时间:2016-04-04 18:23:01

标签: scala apache-spark hiveql

Im executing this query with spark using HiveQL:

var hiveContext = new org.apache.spark.sql.hive.HiveContext(sc)

result = hiveContext.sql("select linestatus, sum(quantity) as sum_qty,count(*) as count_order from lineitem
where shipdate <= '1990-09-16' group by linestatus order by
linestatus")

But Im getting this error:

<console>:1: error: unclosed character literal
       where shipdate <= '1990-09-16' group by linestatus order by

Do you know understand why?

1 个答案:

答案 0 :(得分:5)

Multiline strings in Scala have to be enclosed using triple quotes:

hiveContext.sql("""
    select linestatus, sum(quantity) as sum_qty,count(*) as count_order 
    from lineitem
    where shipdate <= '1990-09-16' group by linestatus order by linestatus""")