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

Logical type : TIME #143

Merged
merged 30 commits into from
Sep 13, 2024
Merged

Logical type : TIME #143

merged 30 commits into from
Sep 13, 2024

Conversation

saraswatpuneet
Copy link
Collaborator

@saraswatpuneet saraswatpuneet commented Sep 9, 2024

Problem

Part of #99
image

Support logical types in parquetjs starting with TIME support

Solution

Implementation following the parquet spec

Change summary:

  • Added a logical type to support parquet types
  • Implemented type conversions for logical type time to primitive type according to spec
  • Implement field, schema and file tests to ensure everything works together

Steps to Verify:

  1. npm run test

@saraswatpuneet saraswatpuneet marked this pull request as ready for review September 11, 2024 18:16
@saraswatpuneet saraswatpuneet changed the title Logical type : TIME [WIP] Logical type : TIME Sep 11, 2024
value: string | bigint | number;
unit: 'MILLIS' | 'MICROS' | 'NANOS';
isAdjustedToUTC: boolean;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Type for handling incoming time type and handle accordingly

test/decodeSchema.js Outdated Show resolved Hide resolved
test/decodeSchema.js Outdated Show resolved Hide resolved
test/jsonSchema.test.ts Show resolved Hide resolved
test/fields.test.ts Show resolved Hide resolved
lib/jsonSchema.ts Outdated Show resolved Hide resolved
if (!fieldValue.items.properties.unit.enum) {
throw new UnsupportedJsonSchemaError('Unit enum is not defined');
}
const unit = fieldValue.items.properties.unit.default || fieldValue.items.properties.unit.enum[0];
Copy link
Collaborator Author

@saraswatpuneet saraswatpuneet Sep 12, 2024

Choose a reason for hiding this comment

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

A question here, how will units be defined in schema, an enum? or plain string. if enum do we initialize all unit types as separate fields?

"unit": {
"type": "string",
"enum": ["MILLIS", "MICROS", "NANOS"],
"description": "The unit for the time value"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How we expect units be defined a string or enum?

Copy link
Member

Choose a reason for hiding this comment

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

I am fine with the enum or string, so what it is now is good by me.

@wilwade wilwade changed the title [WIP] Logical type : TIME Logical type : TIME Sep 12, 2024
Copy link
Collaborator

@shannonwells shannonwells left a comment

Choose a reason for hiding this comment

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

Thanks for adding the tests.

@saraswatpuneet saraswatpuneet merged commit 6b7bea9 into main Sep 13, 2024
1 check passed
@saraswatpuneet saraswatpuneet deleted the logical_type_time branch September 13, 2024 13:16
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.

3 participants