Description
Suppose we have some table in postgresql with field `Last Name` The following code results in error
Dataset<Row> dataset = sparkSession.read()
.format("jdbc")
.option("url", myUrl)
.option("dbtable", "myTable")
.option("user", "myUser")
.option("password", "muPassword")
.load();
dataset.where("`Last Name`='Tessel'").show(); //error
Exception in thread "main" org.apache.spark.sql.catalyst.parser.ParseException:
Syntax error at or near 'Name': extra input 'Name'(line 1, pos 5)
== SQL ==
Last Name
-----^^^
at org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:306)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:143)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parseMultipartIdentifier(ParseDriver.scala:67)
at org.apache.spark.sql.connector.expressions.LogicalExpressions$.parseReference(expressions.scala:40)
at org.apache.spark.sql.connector.expressions.FieldReference$.apply(expressions.scala:368)
at org.apache.spark.sql.sources.IsNotNull.toV2(filters.scala:262)
at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation.$anonfun$unhandledFilters$1(JDBCRelation.scala:278)
at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation.$anonfun$unhandledFilters$1$adapted(JDBCRelation.scala:278)
But if we set pushDownPredicate to false everything works fine.
Attachments
Issue Links
- is duplicated by
-
SPARK-42193 dataframe API filter criteria throwing ParseException when reading a JDBC column name with special characters
- Resolved
- links to