-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-21287][SQL] Move the validation of fetch size from JDBCOptions to JdbcDialect #26230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df889aa
b6f3cae
7316549
78e89c4
f65191f
74f0325
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import java.sql.{Connection, Date, Timestamp} | |
| import org.apache.commons.lang3.StringUtils | ||
|
|
||
| import org.apache.spark.annotation.{DeveloperApi, Since} | ||
| import org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions | ||
| import org.apache.spark.sql.types._ | ||
|
|
||
| /** | ||
|
|
@@ -150,6 +151,20 @@ abstract class JdbcDialect extends Serializable { | |
| def beforeFetch(connection: Connection, properties: Map[String, String]): Unit = { | ||
| } | ||
|
|
||
| /** | ||
| * Do some extra properties validation work in addition to the validation | ||
| * in [[org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions]]. | ||
| * @param properties The connection properties. This is passed through from the relation. | ||
| */ | ||
| def validateProperties(properties: Map[String, String]): Unit = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm.. wait ..
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chose scala Map because i saw the JdbcDialect.beforeFetch accepts scala Map as parameter.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's OK to leave as-is here. |
||
| val fetchSize = properties.getOrElse(JDBCOptions.JDBC_BATCH_FETCH_SIZE, "0").toInt | ||
| require(fetchSize >= 0, | ||
| s"Invalid value `${fetchSize.toString}` for parameter " + | ||
| s"`${JDBCOptions.JDBC_BATCH_FETCH_SIZE}` for dialect ${this.getClass.getSimpleName}. " + | ||
| s"The minimum value is 0. When the value is 0, " + | ||
| "the JDBC driver ignores the value and does the estimates.") | ||
| } | ||
|
|
||
| /** | ||
| * Escape special characters in SQL string literals. | ||
| * @param value The string to be escaped. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we could just remove this condition and set it as is, and then expect the DBMS to throw an error as well. Seems like Postgres throws an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDTY @srowen, @maropu, @wangyum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just put the discussion on SPARK-21287 here for reference :
https://issues.apache.org/jira/browse/SPARK-21287
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think that's fine too. It isn't really supposed to be negative, but there's one notable exception in MySQL's driver. Even so, we don't manually check other settings here, and so yeah I don't know if there's much value in this check in the end. I'd be OK just removing it entirely too.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srowen @HyukjinKwon I think both of these two solutions should be ok, so I submitted another PR #26244 which just remove the check of non-negative condition in JDBCOptions.
You can decide which one to follow up, i'll close the other.