Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/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
scala数据帧中的regexp_extract给出错误_Scala_Apache Spark - Fatal编程技术网

scala数据帧中的regexp_extract给出错误

scala数据帧中的regexp_extract给出错误,scala,apache-spark,Scala,Apache Spark,我正在尝试将下面的配置单元SQL语句转换为Spark dataframe并得到错误 trim(regexp_extract(message_comment_txt, '(^.*paid\\s?\\$?)(.*?)(\\s?toward.*)', 2)) 示例数据:message\u comment\u txt=“DAY READER,已支付12.76美元的费用” 我需要将输出设置为12.76 请帮助我提供等效的spark dataframe语句 尝试使用付费\\s+(.**?\\s+)正则表达

我正在尝试将下面的配置单元SQL语句转换为Spark dataframe并得到错误

trim(regexp_extract(message_comment_txt, '(^.*paid\\s?\\$?)(.*?)(\\s?toward.*)', 2))
示例数据:
message\u comment\u txt=“DAY READER,已支付12.76美元的费用”

我需要将输出设置为
12.76


请帮助我提供等效的spark dataframe语句

尝试使用
付费\\s+(.**?\\s+)
正则表达式

df.withColumn("extract",regexp_extract(col("message_comment_txt"),"paid\\s+(.*?)\\s+toward",1)).show(false)
//for case insensitive
df.withColumn("extract",regexp_extract(col("message_comment_txt"),"(?i)paid\\s+(.*?)\\s+(?i)toward",1)).show(false)
//+--------------------------------------+-------+
//|message_comment_txt                   |extract|
//+--------------------------------------+-------+
//|DAY READER, paid 12.76 toward the cost|12.76  |
//+--------------------------------------+-------+