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

Use 'Numeric' instead of 'Float' as BQ column type when field type in the json schema is number #162

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

voropaevp
Copy link
Contributor

No description provided.

Copy link
Contributor

@istreeter istreeter left a comment

Choose a reason for hiding this comment

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

This looks great @voropaevp

I asked a couple of questions, which might let you remove a small amount of complexity, but not much. The implementation you've come up with is very simple and I like how the logic is shared between bigquery and parquet types.

Of course it's very important we test thoroughly before releasing it in a loader.

Comment on lines 59 to 66
case Some(CommonProperties.Type.Union(types)) if withNull(types, CommonProperties.Type.Number) =>
schema.multipleOf match {
case Some(NumberProperty.MultipleOf.IntegerMultipleOf(_)) =>
Some(name => Field(name, Type.fromGenericType(decimals.integerType(schema)), Mode.Nullable))
case Some(mult: NumberProperty.MultipleOf.NumberMultipleOf) =>
Some(name => Field(name, numericWithMultiple(mult, schema.maximum, schema.minimum), Mode.Nullable))
case None => None
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you remove this entire block starting from line 59, and let everything fall through to the next case on line 67?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't fall though there, check the onlyNumeric implementation L180.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. OK how about this then:

case Some(CommonProperties.Type.Union(types)) if withNull(types, CommonProperties.Type.Number) || onlyNumeric(types, true) =>

@voropaevp voropaevp requested a review from istreeter April 27, 2023 20:25
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