Github user HyukjinKwon commented on the issue:
https://github.com/apache/spark/pull/14444
I see. It seems using `struct(...)` does not print `struct(...)` but
`named_struct(...)` as specified in `CreateNamedStruct`.
So, the code below:
```scala
scala> spark.range(1).selectExpr("struct(1, 2)").show()
```
prints below:
**Before**
```bash
+------------------+
|struct(col1, col2)|
+------------------+
| [1,2]|
+------------------+
```
**After**
```bash
+------------------------------+
|named_struct(col1, 1, col2, 2)|
+------------------------------+
| [1,2]|
+------------------------------+
```
Would this be necessary to remove both `CreateStruct` and
`CreateStructUnsafe`? I think we might have to introduce common parent if
possible.
BTW, the failed R tests are as below:
```r
df <- createDataFrame(list(list(1L, 2L, 3L), list(4L, 5L, 6L)),
schema = c("a", "b", "c"))
result <- collect(select(df, struct("a", "c")))
expected <- data.frame(row.names = 1:2)
expected$"struct(a, c)" <- list(listToStruct(list(a = 1L, c = 3L)),
listToStruct(list(a = 4L, c = 6L)))
```
```r
> result
named_struct(a, a, c, c)
1 1, 3
2 4, 6
> expected
struct(a, c)
1 1, 3
2 4, 6
```
```r
result <- collect(select(df, struct(df$a, df$b)))
expected <- data.frame(row.names = 1:2)
expected$"struct(a, b)" <- list(listToStruct(list(a = 1L, b = 2L)),
listToStruct(list(a = 4L, b = 5L)))
```
```r
> result
named_struct(a, a, b, b)
1 1, 2
2 4, 5
> expected
struct(a, b)
1 1, 2
2 4, 5
```
Therefore, it seems we definitely need a test for the names as these holes
were identified here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]