You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/06/01 18:44:14 UTC
[GitHub] [arrow-datafusion] alamb commented on issue #6508: octet_length(char) doesn't behave as expected.
alamb commented on issue #6508:
URL: https://github.com/apache/arrow-datafusion/issues/6508#issuecomment-1572597041
Thanks for the report @osawyerr
TLDR is that DataFusion treats `VARCHAR` and `CHAR` the same (because they use the same underlying Arrow type)
🤔 I am not quite sure what to do here. Postgres has the notion of a max width character column `CHAR` but arrow does not . DataFusion maps the SQL type `CHAR` --> arrow type `Utf8`
Thus I am no sure we were be able to replicate the behavior of postgres in this instance.
For anyone following along, here is what postgres does
```sql
postgres=# create table example(name varchar(20));
CREATE TABLE
postgres=# insert into example values ('foo'), ('barrr');
INSERT 0 2
postgres=# select octet_length(name) from example;
octet_length
--------------
3
5
(2 rows)
postgres=# select octet_length(name::char(25)) from example;
octet_length
--------------
25
25
(2 rows)
postgres=# select octet_length(name::varchar(25)) from example;
octet_length
--------------
3
5
(2 rows)
postgres=#
```
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org