-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: develop
Are you sure you want to change the base?
Conversation
… the json schema is number (close #112)
There was a problem hiding this 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.
modules/core/src/main/scala/com.snowplowanalytics/iglu.schemaddl/bigquery/Type.scala
Show resolved
Hide resolved
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 | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) =>
No description provided.