panbingkun commented on PR #48653:
URL: https://github.com/apache/spark/pull/48653#issuecomment-2437104578
Although we can set `ignoreLeadingWhiteSpace` to `true` to display it
correctly, the type `float` & `double` can still be displayed correctly
`without` setting it,
```sql
spark-sql (default)> select from_csv('1, 1', 'a INT, b INT',
map('ignoreLeadingWhiteSpace', 'false'));
from_csv(1, 1)
{"a":1,"b":null}
Time taken: 0.099 seconds, Fetched 1 row(s)
spark-sql (default)> select from_csv('1, 1', 'a INT, b INT',
map('ignoreLeadingWhiteSpace', 'true'));
from_csv(1, 1)
{"a":1,"b":1}
Time taken: 0.037 seconds, Fetched 1 row(s)
```
```
spark-sql (default)> select from_csv('1, 1', 'a INT, b DOUBLE',
map('ignoreLeadingWhiteSpace', 'false'));
from_csv(1, 1)
{"a":1,"b":1.0}
Time taken: 0.065 seconds, Fetched 1 row(s)
spark-sql (default)> select from_csv('1, 1', 'a INT, b DOUBLE',
map('ignoreLeadingWhiteSpace', 'true'));
from_csv(1, 1)
{"a":1,"b":1.0}
Time taken: 0.035 seconds, Fetched 1 row(s)
```
and in most cases, users think it is normal to use `", "` (`Please note that
there is a space after the comma`) to separate fields in `CSV`, as in our
example:
https://github.com/apache/spark/blob/6e82d5946ae73bd0f7d0f9b1826a0e4a29eaaaec/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/csvExpressions.scala#L46-L49
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]