-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28097][SQL] Map ByteType to SMALLINT for PostgresDialect #24845
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
PostgreSQL doesn't have TINYINT, which would map directly, but SMALLINTs are sufficient for uni-directional translation.
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.
Thank you for making a PR, @mojodna .
- In general,
PostgreSQLusers will not use unsupported types.
I'm wondering if your goal is the one you mentioned as side-effectsAggregatedDialect is now usable. Could you describe a little bit more about the use cases? - Also, please create a JIRA issue for this suggestion and use the JIRA id to the PR title. PR is valuable, but JIRA issue also becomes a history.
srowen
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.
File a JIRA, yes. You've checked this works on postgres?
sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala
Outdated
Show resolved
Hide resolved
|
@srowen yes, it works on Postgres. @dongjoon-hyun https://issues.apache.org/jira/browse/SPARK-28100 describes the underlying problem (i.e. why I can't provide a custom dialect with an alternate mapping). The actual use-case is writing spatial data from Spark (using Spark JTS) to Postgres using the JDBC sink (where I may need to map
Some time later, I realized that I can cast my bytes to shorts before handing off to the JDBC sink, so this is more a case of things not working as I'd expect them to. |
gatorsmile
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.
Add a test to PostgresIntegrationSuite?
|
ok to test |
|
@gatorsmile |
|
Test build #106641 has finished for PR 24845 at commit
|
|
@gatorsmile given the comment at #24845 (comment) are you OK with this change? |
|
@mojodna what do you think about adding a simple additional test here to verify? |
|
I'm swamped for the next couple weeks, but sure thing. Is there a specific test within |
|
|
|
Gentle ping, @mojodna . |
|
Thanks @dongjoon-hyun. We just moved and are getting settled in, so sometime next week looks very likely. |
|
Thank you, @mojodna . |
|
Updated. Thanks @maropu for doing the hard part! |
|
Test build #107798 has finished for PR 24845 at commit
|
dongjoon-hyun
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.
+1, LGTM. Merged to master.
Thank you, @mojodna , @srowen , @gatorsmile , @maropu !
|
Thank you so much for your contribution, @mojodna . |
## What changes were proposed in this pull request? PostgreSQL doesn't have `TINYINT`, which would map directly, but `SMALLINT`s are sufficient for uni-directional translation. A side-effect of this fix is that `AggregatedDialect` is now usable with multiple dialects targeting `jdbc:postgresql`, as `PostgresDialect.getJDBCType` no longer throws (for which reason backporting this fix would be lovely): https://github.com/apache/spark/blob/1217996f1574f758d8cccc1c4e3846452d24b35b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/AggregatedDialect.scala#L42 `dialects.flatMap` currently throws on the first attempt to get a JDBC type preventing subsequent dialects in the chain from providing an alternative. ## How was this patch tested? Unit tests. Closes apache#24845 from mojodna/postgres-byte-type-mapping. Authored-by: Seth Fitzsimmons <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
What changes were proposed in this pull request?
PostgreSQL doesn't have
TINYINT, which would map directly, butSMALLINTs are sufficient for uni-directional translation.A side-effect of this fix is that
AggregatedDialectis now usable with multiple dialects targetingjdbc:postgresql, asPostgresDialect.getJDBCTypeno longer throws (for which reason backporting this fix would be lovely):spark/sql/core/src/main/scala/org/apache/spark/sql/jdbc/AggregatedDialect.scala
Line 42 in 1217996
dialects.flatMapcurrently throws on the first attempt to get a JDBC type preventing subsequent dialects in the chain from providing an alternative.How was this patch tested?
Unit tests.