String 已在mysql上验证查询(带有替换函数),但未在spark sql中传递
我在mysql上验证的原始查询如下:String 已在mysql上验证查询(带有替换函数),但未在spark sql中传递,string,apache-spark-sql,String,Apache Spark Sql,我在mysql上验证的原始查询如下: select substring(replace(substring(order_date, 1,10), '-',''),1, 6) as OrderMonth, c.customer_id, round(sum(oi.order_item_subtotal),2) as MonthlyTotal from orders o join order_items oi on oi.order_item_order_id = o.order_id join cu
select substring(replace(substring(order_date, 1,10), '-',''),1, 6) as OrderMonth, c.customer_id, round(sum(oi.order_item_subtotal),2) as MonthlyTotal
from orders o join order_items oi on oi.order_item_order_id = o.order_id
join customers c on c.customer_id = o.order_customer_id
group by substring(replace(substring(order_date, 1,10), '-',''),1, 6), customer_id
order by sum(oi.order_item_subtotal) desc
limit 5;
我在Spark中运行时出错:
scala> val final_result = sqlContext.sql(sql_query)
18/03/14 14:03:58 INFO ParseDriver: Parsing command: select substring(replace(substring(order_date, 1,10), '-',''),1, 6) as OrderMonth, c.customer_id, round(sum(oi.order_item_subtotal),2) as MonthlyTotal
from orders o join order_items oi on oi.order_item_order_id = o.order_id
join customers c on c.customer_id = o.order_customer_id
group by substring(replace(substring(order_date, 1,10), '-',''),1, 6), customer_id
order by sum(oi.order_item_subtotal) desc
limit 5
18/03/14 14:03:58 INFO ParseDriver: Parse Completed
org.apache.spark.sql.AnalysisException: undefined function replace; line 4 pos 60
如何修复该查询?非常感谢。因此,由于未知原因,replace的字符串函数不被接受,我切换到使用regexp\u replace,它现在正常工作 有人能分享一些见解吗?谢谢