-
Couldn't load subscription status.
- Fork 28.9k
[SPARK-18413][SQL][FOLLOW-UP] Use numPartitions instead of maxConnections
#15966
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
7df41a1
48b6d25
f8c67ba
ba8be46
d45467e
f9db374
4a957e4
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 |
|---|---|---|
|
|
@@ -74,19 +74,23 @@ class JDBCOptions( | |
| } | ||
| } | ||
|
|
||
| // the number of partitions | ||
| val numPartitions = parameters.get(JDBC_NUM_PARTITIONS).map(_.toInt) | ||
| require(numPartitions.isEmpty || numPartitions.get > 0, | ||
| s"Invalid value `${numPartitions.get}` for parameter `$JDBC_NUM_PARTITIONS`. " + | ||
| "The minimum value is 1.") | ||
|
|
||
| // ------------------------------------------------------------ | ||
| // Optional parameters only for reading | ||
| // ------------------------------------------------------------ | ||
| // the column used to partition | ||
| val partitionColumn = parameters.getOrElse(JDBC_PARTITION_COLUMN, null) | ||
| val partitionColumn = parameters.get(JDBC_PARTITION_COLUMN) | ||
| // the lower bound of partition column | ||
| val lowerBound = parameters.getOrElse(JDBC_LOWER_BOUND, null) | ||
| val lowerBound = parameters.get(JDBC_LOWER_BOUND).map(_.toLong) | ||
| // the upper bound of the partition column | ||
| val upperBound = parameters.getOrElse(JDBC_UPPER_BOUND, null) | ||
| // the number of partitions | ||
| val numPartitions = parameters.getOrElse(JDBC_NUM_PARTITIONS, null) | ||
| require(partitionColumn == null || | ||
| (lowerBound != null && upperBound != null && numPartitions != null), | ||
| val upperBound = parameters.get(JDBC_UPPER_BOUND).map(_.toLong) | ||
| require(partitionColumn.isEmpty || | ||
| (lowerBound.isDefined && upperBound.isDefined && numPartitions.isDefined), | ||
| s"If '$JDBC_PARTITION_COLUMN' is specified then '$JDBC_LOWER_BOUND', '$JDBC_UPPER_BOUND'," + | ||
| s" and '$JDBC_NUM_PARTITIONS' are required.") | ||
|
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. We need to update this error message too. 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. Ur, for me, this error message looks correct. 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 did not try it. What happened if we input 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.
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. Since it's used in declaration of view, users cannot go to writing path. CREATE OR REPLACE TEMPORARY VIEW t1 USING org.apache.spark.sql.jdbc OPTIONS (url 'jdbc:mysql://localhost:3306/t', dbtable 't1', user 'root', password '', maxConnections '2', partitionColumn 'value')
java.lang.IllegalArgumentException: requirement failed: If 'partitionColumn' is specified then 'lowerBound', 'upperBound', and 'numPartitions' are required.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. Have you tried the |
||
| val fetchSize = { | ||
|
|
@@ -122,11 +126,6 @@ class JDBCOptions( | |
| case "REPEATABLE_READ" => Connection.TRANSACTION_REPEATABLE_READ | ||
| case "SERIALIZABLE" => Connection.TRANSACTION_SERIALIZABLE | ||
| } | ||
| // the maximum number of connections | ||
| val maxConnections = parameters.get(JDBC_MAX_CONNECTIONS).map(_.toInt) | ||
| require(maxConnections.isEmpty || maxConnections.get > 0, | ||
| s"Invalid value `${maxConnections.get}` for parameter `$JDBC_MAX_CONNECTIONS`. " + | ||
| "The minimum value is 1.") | ||
| } | ||
|
|
||
| object JDBCOptions { | ||
|
|
@@ -149,5 +148,4 @@ object JDBCOptions { | |
| val JDBC_CREATE_TABLE_OPTIONS = newOption("createTableOptions") | ||
| val JDBC_BATCH_INSERT_SIZE = newOption("batchsize") | ||
| val JDBC_TXN_ISOLATION_LEVEL = newOption("isolationLevel") | ||
| val JDBC_MAX_CONNECTIONS = newOption("maxConnections") | ||
| } | ||
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.
We should revert it back. These four parameters are related.
These options must all be specified if any of them is specifiedUh 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.
That is incorrect now.
numPartitionscan be used alone. Those three areread-onlyoptional parameters andnumPartitionsare general optional parameter.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.
In the read path, they are still related.
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.
For that, I'll add some other description mentioning the relations.