Daniel Luo
09/09/2024, 3:54 PM"val2":{"inclusion":"available","multipleOf":1e-20,"type":["null","number"]}}
However, this seems to come out in snowflake as a double/float and loses the precision. I see that a potential fix for this is to specify singer_decimal on the tap. In that case, I see that the data type is the following:
"val2":{"inclusion":"available","format":"singer.decimal","type":["null","number","string"],"additionalProperties":{"scale_precision":"(38,20)"}}}
The problem with this approach is that it ends up in snowflake as a varchar. Is this because snowflake target isn't properly supporting singer_decimal?Daniel Luo
09/09/2024, 3:56 PMvisch
09/09/2024, 3:58 PMEdgar Ramírez (Arch.dev)
09/09/2024, 9:03 PMDaniel Luo
09/09/2024, 9:04 PMEdgar Ramírez (Arch.dev)
09/10/2024, 12:36 AM"val2":{"inclusion":"available","format":"singer.decimal","type":["null","number","string"],"additionalProperties":{"scale_precision":"(38,20)"}}}
I can't find a tap-mysql in MeltanoHub that supports that, so I'm curious what variant this is.
FWIW, I've reopened https://github.com/meltano/sdk/issues/1890.Daniel Luo
09/10/2024, 12:38 AMEdgar Ramírez (Arch.dev)
09/10/2024, 12:39 AMvisch
09/10/2024, 12:40 AMDaniel Luo
09/10/2024, 12:41 AMDaniel Luo
09/10/2024, 12:42 AMDaniel Luo
09/10/2024, 12:45 AMEdgar Ramírez (Arch.dev)
09/10/2024, 12:45 AMI haven't finished reading here, but why would this be an sdk issue rather than just snowflake? Or is it to make it easier to implement?I think it makes sense to upstream, but happy to review a target-snowflake PR or just an issue is also fine. target-snowflake has a lot of customization anyway, but I do want to reduce it at some point.
I'm not sure on the implementation details for multiple of, but I did notice that precision is lost at the target. Again, not sure if that's the tap's fault or not though because the output file doesn't lose any precision (edited)I 100% agree. The next version of the SDK will make it easier for SQL taps to customize the SQL->JSON schema mapping, and I have just that as an example: https://sdk.meltano.com/en/latest/guides/sql-tap.html#custom-type-mapping
steve_clarke
09/10/2024, 8:29 AMsinger decimal
and make use of the additional properties. If you use this variant, it will automatically convert and store the data as a number with the correct scale and precision as per the source system.
This has been very important for us as we found during our testing that there is a loss of precision if the numeric based decimal and floats were not emitted as strings via the enablement of singer decimal. I have been meaning to raise a PR to the Meltanolabs version of target-snowflake to add our logic so it could be our preferred loader.
It is worth noting for Oracle Databases however that singer decimal is harder as Oracle doesn't really set a scale and precision. It is often set as just number and the user can store a mix of integers and decimals. If this is the case we will not emit any precision and scale and that data will be transferred as a string. It would be the responsibility of the data transform e.g. dbt to set an appropriate data type as it is too dangerous to guess what is correct. We will still transfer it as a string to avoid python and scientific notation leading rounding issues.steve_clarke
09/10/2024, 9:01 AMDaniel Luo
09/10/2024, 6:11 PM