alamb commented on PR #9537:
URL: https://github.com/apache/arrow-rs/pull/9537#issuecomment-4090300409
> hmmm, should I make changes in some other layer where the performance hit
wouldn't be this much? Any pointers if possible?
>
> @alamb
Well we can use the existing `trim` function in DataFusion
```sql
DataFusion CLI v52.3.0
> select ' 4.5'::float;
Optimizer rule 'simplify_expressions' failed
caused by
Arrow error: Cast error: Cannot cast string ' 4.5' to value of Float32 type
> select trim(' 4.5')::float;
+----------------------+
| btrim(Utf8(" 4.5")) |
+----------------------+
| 4.5 |
+----------------------+
1 row(s) fetched.
Elapsed 0.022 seconds.
```
Interestingly DuckDB does automatically trim
```sql
andrewlamb@Andrews-MacBook-Pro-3:~/Software/influxdb_pro/ent$ duckdb
DuckDB v1.5.0 (Variegata)
Enter ".help" for usage hints.
memory D select ' 4.5'::float;
┌────────────────────────┐
│ CAST(' 4.5' AS FLOAT) │
│ float │
├────────────────────────┤
│ 4.5 │
└────────────────────────┘
```
As does postgres 🤔
```sql
andrewlamb@Andrews-MacBook-Pro-3:~/Software/influxdb_pro/ent$ psql -h
localhost -U postgres
psql (14.22 (Homebrew), server 11.16 (Debian 11.16-1.pgdg90+1))
Type "help" for help.
postgres=# select ' 4.5'::float;
float8
--------
4.5
(1 row)
```
--
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]