Commit 502476e
[SPARK-12010][SQL] Spark JDBC requires support for column-name-free INSERT syntax
In the past Spark JDBC write only worked with technologies which support the following INSERT statement syntax (JdbcUtils.scala: insertStatement()):
INSERT INTO $table VALUES ( ?, ?, ..., ? )
But some technologies require a list of column names:
INSERT INTO $table ( $colNameList ) VALUES ( ?, ?, ..., ? )
This was blocking the use of e.g. the Progress JDBC Driver for Cassandra.
Another limitation is that syntax 1 relies no the dataframe field ordering match that of the target table. This works fine, as long as the target table has been created by writer.jdbc().
If the target table contains more columns (not created by writer.jdbc()), then the insert fails due mismatch of number of columns or their data types.
This PR switches to the recommended second INSERT syntax. Column names are taken from datafram field names.
Author: CK50 <[email protected]>
Closes #10380 from CK50/master-SPARK-12010-2.1 parent 3920466 commit 502476e
File tree
1 file changed
+4
-8
lines changed- sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc
1 file changed
+4
-8
lines changedLines changed: 4 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
74 | 70 | | |
75 | 71 | | |
76 | 72 | | |
| |||
0 commit comments