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

Arrow json decoding #477

Merged
merged 1 commit into from
Jan 3, 2024
Merged

Arrow json decoding #477

merged 1 commit into from
Jan 3, 2024

Conversation

mwylde
Copy link
Member

@mwylde mwylde commented Jan 3, 2024

This PR adds initial support for decoding from JSON into arrow, via a slightly modified version of arrow-json (https://github.com/ArroyoSystems/arrow-rs/tree/49.0.0/json) that adds support for raw json fields.

I've also started the process of moving sources away from StructDef to using native arrow datatypes. In that world, we encode raw json as an extension type with the name arroyo.json. The datafusion project is also thinking about how to support JSON fields (apache/datafusion#7845), so hopefully in the future we'll be able to leverage something more native.

This also includes support for specifying json types in columns:

create table (
  a INT,
  b JSON
)

which will cause b to generate a raw json schema.

There are a few limitations to this initial PR:

  • Due to how arrow-json works, error handling is done at a batch level rather than the individual record level, which means that with BadData::Drop, an entire batch gets dropped for a single bad record
  • Only timestamps in postgres-compatible formats are supported (a superset of RFC3339 / ISO8601); in particular unix epoch millis are not supported
  • The json-schema generator hasn't been updated yet

It's likely that our approach here will evolve, but for now this PR should work for most cases.

@mwylde mwylde merged commit 0ead44e into record_batch_common_dev Jan 3, 2024
8 checks passed
This pull request was closed.
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