-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-33095][SQL] Support ALTER TABLE in JDBC v2 Table Catalog: add, update type and nullability of columns (MySQL dialect) #30025
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
Conversation
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #129739 has finished for PR 30025 at commit
|
78e33ec to
ba7ebdb
Compare
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #129750 has finished for PR 30025 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #129823 has finished for PR 30025 at commit
|
|
|
||
| import org.apache.spark.SparkConf | ||
| import org.apache.spark.sql.AnalysisException | ||
| import org.apache.spark.sql.catalyst.parser.ParseException |
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.
Seems this is not needed?
| import org.apache.spark.sql.catalyst.parser.ParseException | ||
| import org.apache.spark.sql.execution.datasources.v2.jdbc.JDBCTableCatalog | ||
| import org.apache.spark.sql.jdbc.{DatabaseOnDocker, DockerJDBCIntegrationSuite} | ||
| import org.apache.spark.sql.test.SharedSparkSession |
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.
Not needed?
| tableName: String, | ||
| columnName: String, | ||
| newDataType: String): String = { | ||
| s"ALTER TABLE $tableName MODIFY COLUMN $columnName $newDataType" |
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.
please see #30041
|
also cc @cloud-fan @MaxGekk |
1ee7cd6 to
dfd6d4b
Compare
|
Test build #129880 has finished for PR 30025 at commit
|
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
I have updated. First getting schema from the table and taking the type information from the schema and then passing type to alter table update nullability. Hi @huaxingao, thanks for the help ! Please take a look again. @cloud-fan thank you for the suggestion, Please take a look again ! |
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
…te type and nullability of columns (MySQL dialect)
c7f4113 to
230fed8
Compare
|
Kubernetes integration test starting |
|
Test build #130086 has finished for PR 30025 at commit
|
|
Kubernetes integration test status success |
|
Test build #130091 has finished for PR 30025 at commit
|
| JdbcUtils.alterTable(conn, getTableName(ident), changes, options) | ||
| val optionsWithTableName = new JDBCOptions( | ||
| options.parameters + (JDBCOptions.JDBC_TABLE_NAME -> getTableName(ident))) | ||
| val tableSchema: StructType = JdbcUtils.getSchemaOption(conn, optionsWithTableName).get |
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.
ah now I get what you mean. The AlterTable logical plan does have the table schema, but the catalog API doesn't pass it in. It's not possible to change the catalog API at this point, and it's also not worthy to add an extra table lookup here just to support update nullability in MySQL.
I think the first version is fine. Sorry for the back and forth!
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.
Thanks will do so ! 👍
This reverts commit 230fed8.
|
Kubernetes integration test starting |
|
Kubernetes integration test status success |
|
Test build #130138 has finished for PR 30025 at commit
|
|
thanks, merging to master! |
|
Thanks a lot @cloud-fan :) |
What changes were proposed in this pull request?
Override the default SQL strings for:
ALTER TABLE UPDATE COLUMN TYPE
ALTER TABLE UPDATE COLUMN NULLABILITY
in the following MySQL JDBC dialect according to official documentation.
Write MySQL integration tests for JDBC.
Why are the changes needed?
Improved code coverage and support mysql dialect for jdbc.
Does this PR introduce any user-facing change?
Yes, Support ALTER TABLE in JDBC v2 Table Catalog: add, update type and nullability of columns (MySQL dialect)
How was this patch tested?
Added tests.