diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala index a96857ab1024..e34104445967 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala @@ -1342,7 +1342,7 @@ case class ShowCreateTableAsSerdeCommand( storage.serde.foreach { serde => builder ++= s"ROW FORMAT SERDE '$serde'\n" - val serdeProps = conf.redactOptions(metadata.storage.properties).map { + val serdeProps = conf.redactOptions(metadata.storage.properties).toSeq.sortBy(_._1).map { case (key, value) => s"'${escapeSingleQuotedString(key)}' = '${escapeSingleQuotedString(value)}'" } diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/command/ShowCreateTableSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/command/ShowCreateTableSuite.scala index a7d5e7b08348..a2e1ee24f039 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/command/ShowCreateTableSuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/command/ShowCreateTableSuite.scala @@ -128,9 +128,9 @@ class ShowCreateTableSuite extends v1.ShowCreateTableSuiteBase with CommandSuite " ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'" + " WITH SERDEPROPERTIES (" + " 'colelction.delim' = '@'," + + " 'field.delim' = ','," + " 'mapkey.delim' = '#'," + - " 'serialization.format' = ','," + - " 'field.delim' = ',')" + + " 'serialization.format' = ',')" + " STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'" + " OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'" + " TBLPROPERTIES (" @@ -178,9 +178,9 @@ class ShowCreateTableSuite extends v1.ShowCreateTableSuiteBase with CommandSuite val expected = s"CREATE TABLE $fullName ( c1 INT COMMENT 'bla', c2 STRING)" + " ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'" + " WITH SERDEPROPERTIES (" + + " 'field.delim' = ','," + " 'mapkey.delim' = ','," + - " 'serialization.format' = '1'," + - " 'field.delim' = ',')" + + " 'serialization.format' = '1')" + " STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'" + " OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'" + " TBLPROPERTIES ("