dbtsai commented on a change in pull request #27066: [SPARK-31317][SQL] Add
withField method to Column class
URL: https://github.com/apache/spark/pull/27066#discussion_r403359131
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Column.scala
##########
@@ -879,6 +879,17 @@ class Column(val expr: Expression) extends Logging {
*/
def getItem(key: Any): Column = withExpr { UnresolvedExtractValue(expr,
Literal(key)) }
+ /**
+ * An expression that adds/replaces a field by name in a `StructType`.
+ * If schema contains multiple fields with fieldName, they will all be
replaced with fieldValue.
+ *
+ * @group expr_ops
+ * @since 3.1.0
+ */
+ def withField(fieldName: String, fieldValue: Column): Column = withExpr {
Review comment:
By definition, `A column is collection of cells aligned vertically in a
table. A field is an element in which one piece of information is stored, such
as the Received field`.
Wondering if we should rename `withField` to `withColumn`? In this case, we
can have consistent API to `Dataset`.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]