alamb commented on issue #12326: URL: https://github.com/apache/datafusion/issues/12326#issuecomment-2331287085
> Add a scalar function to interpret a binary column as a utf8 string. This allows for explicit conversion between the data types. The function could be named str_from_utf8 or similar. I think you can convert binary to utf8 using a cast like `col::varchar`: ```sql > create table foo as values (X'123'); 0 row(s) fetched. Elapsed 0.011 seconds. > select * from foo; +---------+ | column1 | +---------+ | 0123 | +---------+ 1 row(s) fetched. Elapsed 0.004 seconds. > select arrow_typeof(column1) from foo; +---------------------------+ | arrow_typeof(foo.column1) | +---------------------------+ | Binary | +---------------------------+ 1 row(s) fetched. Elapsed 0.003 seconds. > select column1::varchar from foo; +-------------+ | foo.column1 | +-------------+ | # | +-------------+ 1 row(s) fetched. Elapsed 0.002 seconds. ``` However, I don't think this mechanism allows you to control the casting behavior (error or null), though the underlying arrow cast kernels do: https://docs.rs/arrow/latest/arrow/compute/fn.cast_with_options.html Specifically [CastOptions::safe](https://docs.rs/arrow/latest/arrow/compute/struct.CastOptions.html) -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org