Derk Crezee created SPARK-35309:
-----------------------------------

             Summary: array transform should respect alias in expression
                 Key: SPARK-35309
                 URL: https://issues.apache.org/jira/browse/SPARK-35309
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.1.0
            Reporter: Derk Crezee


When an array is transformed using the transform function in combination with 
an alias, I get an unexpected column name.
{code:scala}
// code placeholder
val data = Seq((Array(1, 2, 3)))
val df = sc.parallelize(data).toDF("a")

val dfRes = df.select(
  transform(
    $"a",
    (col: Column) => struct(col).alias("struct_alias")
  ).alias("a")
)

dfRes.printSchema
// root
//  |-- a: array (nullable = true)
//  |    |-- element: struct (containsNull = false)
//  |    |    |-- x: integer (nullable = false)
{code}

I expected the inner element to have the name 'struct_alias'.




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to