panbingkun commented on PR #48653:
URL: https://github.com/apache/spark/pull/48653#issuecomment-2467641107
> Is this behavior consistent with reading CSV files?
- test.csv
```csv
1, 1
```
- Before this PR
A.schema = "a INT, b DOUBLE"
```scala
test("read csv test.csv") {
val df = spark.read.schema("a INT, b
DOUBLE").csv(testFile("test-data/test.csv"))
df.show(true)
}
```
result
```
+---+---+
| a| b|
+---+---+
| 1|1.0|
+---+---+
```
B.schema = "a INT, b INT"
```scala
test("read csv test.csv") {
val df = spark.read.schema("a INT, b
INT").csv(testFile("test-data/test.csv"))
df.show(true)
}
```
result
```
+---+----+
| a| b|
+---+----+
| 1|NULL|
+---+----+
```
- After this PR
A.schema = "a INT, b DOUBLE"
```scala
test("read csv test.csv") {
val df = spark.read.schema("a INT, b
DOUBLE").csv(testFile("test-data/test.csv"))
df.show(true)
}
```
result:
```
+---+---+
| a| b|
+---+---+
| 1|1.0|
+---+---+
```
B.schema = "a INT, b INT"
```scala
test("read csv test.csv") {
val df = spark.read.schema("a INT, b
INT").csv(testFile("test-data/test.csv"))
df.show(true)
}
```
result:
```
+---+---+
| a| b|
+---+---+
| 1| 1|
+---+---+
```
--
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]