【发布时间】:2019-11-04 13:31:52
【问题描述】:
我的数据如下:
>>> df1.show()
+-----------------+--------------------+
| corruptNames| standardNames|
+-----------------+--------------------+
|Sid is (Good boy)| Sid is Good Boy|
| New York Life| New York Life In...|
+-----------------+--------------------+
因此,根据上述数据,我需要应用正则表达式,创建一个新列并获取第二列中的数据,即standardNames。我试过下面的代码:
spark.sql("select *, case when corruptNames rlike '[^a-zA-Z ()]+(?![^(]*))' or corruptNames rlike 'standardNames' then standardNames else 0 end as standard from temp1").show()
它抛出以下错误:
pyspark.sql.utils.AnalysisException: "cannot resolve '`standardNames`' given input columns: [temp1.corruptNames, temp1. standardNames];
【问题讨论】:
-
有人看这个吗?
-
列名
temp1. standardNames有一个额外的前导空格。
标签: hadoop pyspark pyspark-sql