Fokko commented on issue #159: URL: https://github.com/apache/iceberg-rust/issues/159#issuecomment-1887912820
First of all, thanks for the explanation of the Literal. > This sounds a good idea to me, which doesn't introduce extra maintain effort. The only concern is that it maybe not quite user friendly, but it seems that we can add some api to make it easier to use. I think the user should not care about the type of the field. We have the information once we bind to the schema. In extend to that, it can also be that a field has evolved from an int to a long, so you have to convert it anyway based om the file schema. > Regarding @Fokko's example: Doesn't initially storing the Decimal as a LiteralFloat loose accuracy because the 3.25 is stored as something like 3.24999999987. If you then convert it to Decimal, it's inaccurate. Maybe you could use PrimitiveLiteral::String here. This should not happen in practice, because you would only do safe conversions. For example, the expression `a > 3.25` should parse to an expression that has enough precision to capture the original value. If `a` would be of type `float`, then you would convert the literal to a float one once you bind to the schema. > Error message is just an example, not all use cases. For example when we convert unbound expression to bound expression, how do we know its original scale? Also in the case of evolution, the precision can be widened. When we bind the decimal to the actual schema, we'll [set the scale using `set_scale`](https://docs.rs/rust_decimal/latest/rust_decimal/struct.Decimal.html#method.set_scale). > String is enough for storing decimal, or everything, but it maybe weird in api, since with only a string we don't know its original type, e.g. user may write an unbound expression like a < "3.23", where a is a decimal and it's legal to compare it with string. SQL is a perfect example of that API I would say. Once you resolve the type of `a < "3.23"`, [you'll call `i128::from_str("3.23")`](https://docs.rs/rust_decimal/latest/rust_decimal/prelude/trait.FromStr.html#tymethod.from_str). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org