Skip to content

Destination S3 Data Lake: Write objects+unions as stringified json - #51042

Merged
Edward Gao (edgao) merged 14 commits into
masterfrom
edgao/iceberg_stringify_json
Jan 15, 2025
Merged

Edward Gao (edgao) merged 14 commits into
masterfrom
edgao/iceberg_stringify_json

Conversation

@edgao

@edgao Edward Gao (edgao) commented Jan 10, 2025 •

Copy link
Copy Markdown
Contributor

closes https://github.com/airbytehq/airbyte-internal-issues/issues/11272. Stacked on #51044

see slack. We'll start writing sub-objects as JSON strings instead of deeply-typed structs.

this isn't really the right approach, but it's the shortest path to getting something released for the beta, and Johnny Schmidt (@johnny-schmidt) is working on a refactor in the type/value area anyway

commits in sequence:

  1. Bulk Load CDK: fix airbytevalue serialize #51044 (github isn't letting me change the base branch >.>)
  2. extracting coerce logic from the mapper to a separate class (ended up not needing this, but feels like an improvement anyway)
  3. make the coerce mapper configurable to not recurse into specific types
  4. genericize that "not recursing" configuration to all mappers
    1. add two mappers for iceberg functionality
  5. update iceberg logic to write data correctly
  6. update tests to expect the stringified JSON values
  7. update destination-s3 tests (no functionality change, just fixing the compile signature)

@vercel

vercel Bot commented Jan 10, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 5:22pm

@edgao

Edward Gao (edgao) commented Jan 10, 2025 •

Copy link
Copy Markdown
Contributor Author

Johnny Schmidt (@johnny-schmidt) PR is generally still in draft, but can you take a look at the second two commits? (https://github.com/airbytehq/airbyte/pull/51042/files/650337c31fb863d8ef61e040832e37944d45608c..be76c2277466cdd31330d49b930c211c48da14e6)

i.e.

  • AirbyteValueIdentityMapper can now be configured as non-recursive
  • ditto for the DeepCoercingMapper
  • and adding the IcebergNullOutOfRangeIntegers, which is (my current) understanding of what we want for iceberg

just want to check if there's a better way to accomplish this / if I missed some weird behavior

@edgao

Copy link
Copy Markdown
Contributor Author

Francis Genet (@frifriSF59) I pushed a few commits to address the stuff we talked about live + your PR comments https://github.com/airbytehq/airbyte/pull/51042/files/ea27d7a0c6bbab28faf955febb43ac53907acab2..9003b5006f7b973cb85c7db510c5a1d7b81815bc

(CI failures were the compile fail, which is now fixed, and some transient S3 stuff - hopefully should pass on the next try)

* [AirbyteValue]. In particular, this class will parse temporal types, and performs some
* common-sense conversions among numeric types, as well as upcasting any value to StringValue.
*/
object AirbyteValueCoercer {

@johnny-schmidt Johnny Schmidt (johnny-schmidt) Jan 15, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 pulling this out into its own object

promoteUnionToObject = false,
unionBehavior = UnionBehavior.PASS_THROUGH,
schematizedObjectBehavior = SchematizedNestedValueBehavior.PASS_THROUGH,
schematizedArrayBehavior = SchematizedNestedValueBehavior.PASS_THROUGH,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dq, why do we need these if we have ExpectedRecordMapper?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mild opinion, we should keep the expected record mappers as simple as possible (in particular: ideally not even looking at the expected schema), to avoid accidentally papering over bugs in the connector

i.e. when possible, I'd rather make the tests configurable to generate valid expected records, rather than expecting connectors to handle it via an expectedrecordmapper.

(the existing expected record mappers are basically trivial conversions between AirbyteValue types, which I feel better about. But e.g. the object thing would require the mapper to look at the schema, recognize which fields are ObjectType, and prune/null properties - which feels like too much?)

but again, only a mild opinion. This is adding a lot of complexity+repetition in the test code, which is also bad.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you're right as long as we limit the features in the tests to match the features in the CDK.

So: yes to "configure the tests to blobify complex types, validate against schema" (everything under -- CDK -- in types), but no to "configure the tests to merge unions, expect numeric timestamps, etc" (everything under -- CONNECTOR DEV --).

Basically, if you aren't making a change to the CDK, you should not be adding flags to the test framework either?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This also means that maybe there's a way to use the destination's configuration to configure the tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

aha. yeah I think that sounds right. And then we can say - if a toolkit has a (schema/value) mapper, it should probably also provide a corresponding expected record mapper

@edgao
Edward Gao (edgao) enabled auto-merge (squash) January 15, 2025 17:16
@octavia-squidington-iii Octavia Squidington III (octavia-squidington-iii) added the area/documentation Improvements or additions to documentation label Jan 15, 2025
@edgao
Edward Gao (edgao) merged commit 5c90a7e into master Jan 15, 2025
@edgao
Edward Gao (edgao) deleted the edgao/iceberg_stringify_json branch January 15, 2025 17:41

This branch was successfully deployed

1 active deployment
Preview — 8c83f3b0 Deployed Jan 15, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants