Skip to content

Conversation

@HyukjinKwon
Copy link
Member

What changes were proposed in this pull request?

Currently, JdbcUtils.savePartition is doing type-based dispatch for each row to write appropriate values.

So, appropriate setters for PreparedStatement can be created first according to the schema, and then apply them to each row. This approach is similar with CatalystWriteSupport.

This PR simply make the setters to avoid this.

How was this patch tested?

Existing tests should cover this.

@SparkQA
Copy link

SparkQA commented Jul 23, 2016

Test build #62745 has finished for PR 14323 at commit 8cac7de.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 25, 2016

Test build #62814 has finished for PR 14323 at commit 81d8aca.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member Author

Hi @cloud-fan , this one is about writing. Could you please take a look?

// and then setting into a field for `PreparedStatement`. The last argument
// `Int` means the index for the value to be set in the SQL statement and also used
// for the value to retrieve from `Row`.
private type JDBCValueGetter = (PreparedStatement, Row, Int) => Unit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I think setter is a more proper name here, and we should use getter for the read path.

JDBCValueGetter, sounds like we get the value from JDBC.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! thanks!

// A `JDBCValueSetter` is responsible for converting and setting a value from `Row` into
// a field for `PreparedStatement`. The last argument `Int` means the index for the
// value to be set in the SQL statement and also used for the value in `Row`.
private type JDBCValueSetter = (PreparedStatement, Row, Int) => Unit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename the read path too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@SparkQA
Copy link

SparkQA commented Jul 26, 2016

Test build #62863 has finished for PR 14323 at commit c33bb62.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 26, 2016

Test build #62867 has finished for PR 14323 at commit ab4a1cf.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jul 26, 2016

Test build #62868 has finished for PR 14323 at commit fb0f9a8.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@asfgit asfgit closed this in 3b2b785 Jul 26, 2016
zzcclp added a commit to zzcclp/spark that referenced this pull request Jul 27, 2016
…riting apache#14323

[MINOR] Remove extra anonymous closure within functional transformations apache#12382  just JdbcUtils.scala
@HyukjinKwon HyukjinKwon deleted the SPARK-16675 branch January 2, 2018 03:39

case ArrayType(et, _) =>
// remove type length parameters from end of type name
val typeName = getJdbcType(et, dialect).databaseTypeDefinition
Copy link

@jneira-stratio jneira-stratio Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late to the party 😝 but why the type name is converted to lower case?
It makes code trying to get a JDBCType enum value using the string fails with: java.lang.IllegalArgumentException: No enum constant java.sql.JDBCType.varchar 😞
//cc @HyukjinKwon

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as the original code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants