amaliujia commented on code in PR #38475:
URL: https://github.com/apache/spark/pull/38475#discussion_r1012464469


##########
connector/connect/src/main/scala/org/apache/spark/sql/connect/planner/SparkConnectPlanner.scala:
##########
@@ -123,6 +125,24 @@ class SparkConnectPlanner(plan: proto.Relation, session: 
SparkSession) {
     logical.Range(start, end, step, numPartitions)
   }
 
+  private def transformRenameColumns(rel: proto.RenameColumns): LogicalPlan = {
+    val input = new QueryExecution(session, 
transformRelation(rel.getInput)).analyzed
+    if (input.schema.size != rel.getColumnNamesCount) {
+      throw InvalidPlanInput(
+        "The number of columns doesn't match.\n" +
+          s"Old column names (${input.schema.size}): "
+          + input.schema.fields.map(_.name).mkString(", ") + "\n" +
+          s"New column names (${rel.getColumnNamesCount}): "
+          + rel.getColumnNamesList.asScala.mkString(", "))
+    }
+
+    val newCols =
+      input.output.zip(rel.getColumnNamesList.asScala).map { case 
(oldAttribute, newName) =>
+        Alias(oldAttribute, newName)()
+      }
+    logical.Project(newCols, input)

Review Comment:
   Correct me if I am wrong:
   
   `toDF(String*)` has a varargs parameter and I found there is no way to pass 
a list/seq to it. We need update API to `toDF(String_*)`. Will this make it 
become a API change we probably shouldn't do it now?



-- 
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]

Reply via email to