Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 已在mysql上验证查询(带有替换函数),但未在spark sql中传递_String_Apache Spark Sql - Fatal编程技术网

String 已在mysql上验证查询(带有替换函数),但未在spark sql中传递

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

我在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 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,它现在正常工作

有人能分享一些见解吗?谢谢