cod*_*din 2 scala hiveql apache-spark
我使用HiveQL用spark执行此查询:
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")
Run Code Online (Sandbox Code Playgroud)
但是我得到这个错误:
<console>:1: error: unclosed character literal
where shipdate <= '1990-09-16' group by linestatus order by
Run Code Online (Sandbox Code Playgroud)
你知道为什么吗?
Scala中的多行字符串必须使用三引号引起来:
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""")
Run Code Online (Sandbox Code Playgroud)