You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/03/31 22:24:57 UTC

[GitHub] [spark] fqaiser94 commented on issue #27066: [SPARK-31317][SQL] Add withField method to Column class

fqaiser94 commented on issue #27066: [SPARK-31317][SQL] Add withField method to Column class
URL: https://github.com/apache/spark/pull/27066#issuecomment-606915219
 
 
   @dbtsai here is an example explain output with the current implementation: 
   ```
   val df = spark.createDataFrame(sparkContext.parallelize(
     Row(Row(1, 2, 3)) :: Nil),
     StructType(Seq(StructField("a", StructType(Seq(
       StructField("a", IntegerType),
       StructField("b", IntegerType),
       StructField("c", IntegerType)))))))
   
   val result = df.withColumn("a", 'a.withField("d", lit(4)))
   
   result.show()
   
   +------------+
   |           a|
   +------------+
   |[1, 2, 3, 4]|
   +------------+
   
   
   result.explain(true)
   
   == Parsed Logical Plan ==
   'Project [add_fields('a, d, 4) AS a#3]
   +- LogicalRDD [a#1], false
   
   == Analyzed Logical Plan ==
   a: struct<a:int,b:int,c:int,d:int>
   Project [add_fields(a#1, d, 4) AS a#3]
   +- LogicalRDD [a#1], false
   
   == Optimized Logical Plan ==
   Project [add_fields(a#1, d, 4) AS a#3]
   +- LogicalRDD [a#1], false
   
   == Physical Plan ==
   *(1) Project [add_fields(a#1, d, 4) AS a#3]
   +- *(1) Scan ExistingRDD[a#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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org