cloud-fan commented on code in PR #40779:
URL: https://github.com/apache/spark/pull/40779#discussion_r1165557122


##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -272,16 +272,32 @@ class Dataset[T] private[sql](
       numRows: Int,
       truncate: Int): Seq[Seq[String]] = {
     val newDf = toDF()
-    val castCols = newDf.logicalPlan.output.map { col =>
-      // Since binary types in top-level schema fields have a specific format 
to print,
-      // so we do not cast them to strings here.
-      if (col.dataType == BinaryType) {
-        Column(col)
-      } else {
-        Column(col).cast(StringType)
-      }
+    val data = newDf.logicalPlan match {

Review Comment:
   to deduplicate code, how about
   ```
   val newDf = logicalPlan match {
     case c: CommandResult =>
       Dataset.ofRows(sparkSession, LocalRelation(c.output, c.rows)
     case _ => toDf()
   }
   same code as before...
   ```



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