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

[gcp] Fix BQ BIGNUMERIC type support #5428

Merged
merged 1 commit into from
Jul 11, 2024
Merged

[gcp] Fix BQ BIGNUMERIC type support #5428

merged 1 commit into from
Jul 11, 2024

Conversation

RustedBones
Copy link
Contributor

@RustedBones RustedBones commented Jul 11, 2024

BIGNUMERIC is currently not properly supported.

  • toTable cannot infer a schema of type BIGNUMERIC
  • reading from a BIGNUMERIC table returns badly converted BigDecimal (using wrong scale/precision)

Introduce new type BigNumeric to solve this issue

Comment on lines -53 to -54
s"POINT($i $i)", // geography is not an avro logical type
s"""{"value":$i}""" // json is not an avro logical type
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found out that BQ adds custom sqlType property to the schema. We can reconstruct the original type

q"""(r: _root_.org.apache.avro.generic.GenericRecord) => {
import _root_.scala.jdk.javaapi.CollectionConverters._
${constructor(tpe, tn)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is technically an Ident(TermName("r")), adapt macro

Copy link
Contributor

@kellen kellen left a comment

Choose a reason for hiding this comment

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

nice!

Copy link

codecov bot commented Jul 11, 2024

Codecov Report

Attention: Patch coverage is 58.33333% with 10 lines in your changes missing coverage. Please review.

Project coverage is 61.12%. Comparing base (b52036a) to head (e09ffa0).

Files Patch % Lines
.../scala/com/spotify/scio/bigquery/StorageUtil.scala 0.00% 6 Missing ⚠️
...cala/com/spotify/scio/bigquery/types/package.scala 73.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5428      +/-   ##
==========================================
+ Coverage   61.09%   61.12%   +0.03%     
==========================================
  Files         310      311       +1     
  Lines       11060    11075      +15     
  Branches      769      764       -5     
==========================================
+ Hits         6757     6770      +13     
- Misses       4303     4305       +2     

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

@RustedBones RustedBones merged commit c5926d6 into main Jul 11, 2024
12 checks passed
@RustedBones RustedBones deleted the bigquery-bignumeric branch July 11, 2024 14:59
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.

2 participants