-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-44262][SQL] Add dropTable and getInsertStatement to JdbcDialect
#41855
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
4ed366d to
06ddb9a
Compare
MaxGekk
left a comment
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.
other JdbcDialect like Neo4J
@Hisoka-X What's the issue Neo4J? Could you provide more details in PR's description, please.
LGTM in general.
|
cc @sadikovi FYI |
DropTable to JdbcDialectDropTable and getInsertStatement to JdbcDialect
|
@fbiville Hi, can you tell us more detail about how neo4j use |
Already Update. FYI, also move |
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
Outdated
Show resolved
Hide resolved
DropTable and getInsertStatement to JdbcDialectdropTable and getInsertStatement to JdbcDialect
Hello, I experimented using https://github.com/neo4j-contrib/neo4j-jdbc and a third-party, closed-source SDK based on Spark. The Neo4j JDBC connector supports only Cypher queries, not SQL queries. After a conversation with the third-party maintainer, I learnt they were calling However, I quickly realize that supplying a Neo4j dialect would not be enough, as some SQL statements are hardcoded directly in Does that help? |
|
Hi @MaxGekk , can you continue review this PR? Please. |
|
Since the 3.5.0 rc3 will failed, shell we add this PR to 3.5.0 now? @cloud-fan @MaxGekk @HyukjinKwon |
|
Nah, let's don't add a new API to 3.5.0 at this moment. |
Got it, let me change since to 4.0.0 |
| * @return The SQL query to use for insert data into table. | ||
| */ | ||
| @Since("4.0.0") | ||
| def getInsertStatement( |
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.
let's use consistent naming in this file. How about def insertIntoTable?
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.
My concerns is this method only return sql string statement, not do insert into table.
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 already have createTable, alterTable, and you just added dropTable :)
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 mean the behavior of getInsertStatement is return the string SQL, unlike createTable, alterTable,dropTable do create/alter/drop to database. The getInsertStatement dosen't insert data into table, it just used to prepare JDBCStatement, change it to insertIntoTable seem like not match with it behavior.
oh just realized that other method doesn't actually perform either. Let me change it.
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.
Another question, createTable do create table, but other method just return SQL string, should we let createTable only return string to make JdbcDialect behave more consistently?
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
Outdated
Show resolved
Hide resolved
c9f38da to
02339a3
Compare
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
Outdated
Show resolved
Hide resolved
4beea08 to
a9dfc49
Compare
beliefer
left a comment
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.
LGTM if tests passed.
cc @cloud-fan
| rddSchema: StructType, | ||
| tableSchema: Option[StructType], | ||
| isCaseSensitive: Boolean, | ||
| dialect: JdbcDialect): String = { |
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.
note: getInsertStatement is not a public API but we don't stop people from calling JdbcUtils as there is no private[spark]. I'm fine keeping it to avoid troubles for third-party Spark vendors.
|
+1, LGTM. Merging to master. |
|
Thanks @MaxGekk and all! |
What changes were proposed in this pull request?
dropTablefunction toJdbcDialect. So user can override dropTable SQL by other JdbcDialect like Neo4JNeo4J Drop case
MATCH (m:Person {name: 'Mark'}) DELETE mgetInsertStatementfor same reason.Neo4J Insert case
MATCH (p:Person {name: 'Jennifer'}) SET p.birthdate = date('1980-01-01') RETURN pNeo4J SQL(in fact named
CQL) not like normal SQL, but it have JDBC driver.Why are the changes needed?
Make JdbcDialect more useful
Does this PR introduce any user-facing change?
No
How was this patch tested?
exist test