mrob95 commented on issue #957:
URL:
https://github.com/apache/arrow-datafusion/issues/957#issuecomment-1167635697
Did a little digging on this. Postgres gives a similar error:
```
postgres=# select * from test;
abc
-----------
1.2
1.2 hello
1
(3 rows)
postgres=# select abc, cast(abc as int) from test;
ERROR: invalid input syntax for type integer: "1.2"
```
The code which actually does the cast and produce is the error message in
the OP is in the [arrow cast kernel here]
(https://github.com/apache/arrow-rs/blob/master/arrow/src/compute/kernels/cast.rs#L1477).
It calls the `parse` function from the `lexical_core` library to do the actual
parsing.
`lexical_core` has an alternative function - `parse_partial`, which ["parses
until an invalid digit is found (or the end of the string), returning the
number of processed digits and the parsed value until that
point."](https://docs.rs/lexical-core/latest/lexical_core/fn.parse_partial.html).
Options I can see for closing this issue are:
1. Accept the current behaviour, which seems to match what postgres does.
2. Update the arrow kernel to use `parse_partial`, which is more lenient
about the input format, for all casts.
3. Add a `strict` flag to the arrow `CastOptions` struct, and then expose
cast options to datafusion in some way.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]