maropu commented on a change in pull request #29939:
URL: https://github.com/apache/spark/pull/29939#discussion_r500016049
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/DataFrameReader.scala
##########
@@ -333,9 +333,26 @@ class DataFrameReader private[sql](sparkSession:
SparkSession) extends Logging {
assertNoSpecifiedSchema("jdbc")
// properties should override settings in extraOptions.
this.extraOptions ++= properties.asScala
- // explicit url and dbtable should override all
- this.extraOptions ++= Seq(JDBCOptions.JDBC_URL -> url,
JDBCOptions.JDBC_TABLE_NAME -> table)
- format("jdbc").load()
+ // explicit url should override all
+ this.extraOptions ++= Seq(JDBCOptions.JDBC_URL -> url)
+
+ import sparkSession.sessionState.analyzer.NonSessionCatalogAndIdentifier
+
+ this.source = "jdbc"
+ if (table.contains(" ")) { // if table is not a table name, e.g. a SELECT
statement
Review comment:
What if we don't have this check?
```
this.source = "jdbc"
sparkSession.sessionState.sqlParser.parseMultipartIdentifier(table)
match {
case _ @ NonSessionCatalogAndIdentifier(_, _) =>
this.table(table)
case _ =>
// explicit dbtable should override all
this.extraOptions += JDBCOptions.JDBC_TABLE_NAME -> table
load
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]