我需要根据列值应以预定义字符串开头的条件过滤数据框。
我正在尝试以下操作:
val domainConfigJSON = sqlContext.read
.jdbc(url, "CONFIG", prop)
.select("DID", "CONF", "KEY").filter("key like 'config.*'")
并获得异常:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'KEY = 'config.*'' at line 1
Using spark: 1.6.1
最佳答案
您可以使用 startsWith
Column 类中存在的函数。
myDataFrame.filter(col("columnName").startswith("PREFIX"))
关于apache-spark - 以字符串开头的 Spark Dataframe 搜索列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45552293/