Skip to content
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

[DOP-15564] Avoid urlencoding JDBC params #268

Merged
merged 1 commit into from
May 2, 2024
Merged

Conversation

dolfinus
Copy link
Member

@dolfinus dolfinus commented Apr 26, 2024

Change Summary

Instead of passing JDBC(extra={"option1": "value1", "option2": "value2"}) values as query part of JDBC URL procotol://host:port/database?option1=value1&option2=value2, use java.util.Properties map to pass these options directly to a driver. This avoids unnecessary urlencode+urldecode.

To check that properties are really passed to a driver, added integration tests with passing some value with wrong type (e.g. string where integer was expected, and so on), and checking that connection cannot be established.

The only database left intact is Teradata because there is no Teradata docker image to run integration tests with, and also it is specifically mentioned in documentation that most of parameters are read from the URL only.

Also replaced spark.read.jdbc(...) and df.write.jdbc(...) with spark.read.format("jdbc").options(...).load() and df.write.format("jdbc").options(...).save(). Arguments of prior functions have different names (e.g. partition_column vs. column), but options have the same name for both.

Related issue number

Checklist

  • Commit message and PR title is comprehensive
  • Keep the change as small as possible
  • Unit and integration tests for the changes exist
  • Tests pass on CI and coverage does not decrease
  • Documentation reflects the changes where applicable
  • docs/changelog/next_release/<pull request or issue id>.<change type>.rst file added describing change
    (see CONTRIBUTING.rst for details.)
  • My PR is ready to review.

Copy link

codecov bot commented Apr 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.44%. Comparing base (4f55fdc) to head (4a42cd5).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #268      +/-   ##
===========================================
- Coverage    94.45%   94.44%   -0.02%     
===========================================
  Files          204      204              
  Lines         7978     7999      +21     
  Branches      1403     1404       +1     
===========================================
+ Hits          7536     7555      +19     
- Misses         319      320       +1     
- Partials       123      124       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dolfinus dolfinus merged commit 5417dc5 into develop May 2, 2024
42 checks passed
@dolfinus dolfinus deleted the feature/DOP-15564 branch May 2, 2024 09:24
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.

None yet

2 participants