From 8da00228c2c09deebde461c2769afcd29392fd1b Mon Sep 17 00:00:00 2001 From: Terry Kim Date: Sat, 30 Oct 2021 22:23:30 -0700 Subject: [PATCH] sort by keys --- .../apache/spark/sql/execution/command/ddl.scala | 2 +- .../datasources/v2/DescribeNamespaceExec.scala | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala index 36a17a9e004d5..295838eda5a72 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala @@ -191,7 +191,7 @@ case class DescribeDatabaseCommand( if (properties.isEmpty) { "" } else { - properties.toSeq.mkString("(", ", ", ")") + properties.toSeq.sortBy(_._1).mkString("(", ", ", ")") } result :+ Row("Properties", propertiesStr) } else { diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DescribeNamespaceExec.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DescribeNamespaceExec.scala index 310bfb0c70430..a965355ec724e 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DescribeNamespaceExec.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DescribeNamespaceExec.scala @@ -44,12 +44,13 @@ case class DescribeNamespaceExec( } if (isExtended) { - val properties = metadata.asScala.toMap -- CatalogV2Util.NAMESPACE_RESERVED_PROPERTIES - val propertiesStr = if (properties.isEmpty) { - "" - } else { - properties.toSeq.mkString("(", ", ", ")") - } + val properties = metadata.asScala -- CatalogV2Util.NAMESPACE_RESERVED_PROPERTIES + val propertiesStr = + if (properties.isEmpty) { + "" + } else { + properties.toSeq.sortBy(_._1).mkString("(", ", ", ")") + } rows += toCatalystRow("Properties", propertiesStr) } rows.toSeq