-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-38054][SQL] Supports list namespaces in JDBC v2 MySQL dialect #35355
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
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2dd6350
[SPARK-38054][SQL] DS V2 supports list namespaces of MySQL
beliefer c6a9542
Update code
beliefer f220c56
Update code
beliefer b6efaa8
Update code
beliefer 29d8da5
Update code
beliefer 4978c25
Update code
beliefer 826c00f
Update code
beliefer b3a1c3b
Update code
beliefer 19fb6cd
Update sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects…
beliefer d3a004d
Update code
beliefer 5182cdf
Merge branch 'SPARK-38054' of github.com:beliefer/spark into SPARK-38054
beliefer daa11d2
Update code
beliefer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
|
|
||
| package org.apache.spark.sql.jdbc | ||
|
|
||
| import java.sql.{Connection, Date, Timestamp} | ||
| import java.sql.{Connection, Date, Statement, Timestamp} | ||
| import java.time.{Instant, LocalDate} | ||
| import java.util | ||
|
|
||
|
|
@@ -229,6 +229,45 @@ abstract class JdbcDialect extends Serializable with Logging{ | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Create schema with an optional comment. Empty string means no comment. | ||
| */ | ||
| def createSchema(statement: Statement, schema: String, comment: String): Unit = { | ||
| val schemaCommentQuery = if (comment.nonEmpty) { | ||
| // We generate comment query here so that it can fail earlier without creating the schema. | ||
| getSchemaCommentQuery(schema, comment) | ||
|
Contributor
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. let's leave a comment: "We generate comment query here so that it can fail earlier without creating the schema." |
||
| } else { | ||
| comment | ||
| } | ||
| statement.executeUpdate(s"CREATE SCHEMA ${quoteIdentifier(schema)}") | ||
| if (comment.nonEmpty) { | ||
| statement.executeUpdate(schemaCommentQuery) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Check schema exists or not. | ||
| */ | ||
| def schemasExists(conn: Connection, options: JDBCOptions, schema: String): Boolean = { | ||
| val rs = conn.getMetaData.getSchemas(null, schema) | ||
| while (rs.next()) { | ||
| if (rs.getString(1) == schema) return true; | ||
| } | ||
| false | ||
| } | ||
|
|
||
| /** | ||
| * Lists all the schemas in this table. | ||
| */ | ||
| def listSchemas(conn: Connection, options: JDBCOptions): Array[Array[String]] = { | ||
| val schemaBuilder = ArrayBuilder.make[Array[String]] | ||
| val rs = conn.getMetaData.getSchemas() | ||
| while (rs.next()) { | ||
| schemaBuilder += Array(rs.getString(1)) | ||
| } | ||
| schemaBuilder.result | ||
| } | ||
|
|
||
| /** | ||
| * Return Some[true] iff `TRUNCATE TABLE` causes cascading default. | ||
| * Some[true] : TRUNCATE TABLE causes cascading. | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the actual change here? Get rid of the try-catch in
createNamespaceComment?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.
I want keep the atomic of create namespace with comment.