From 94a5f9cef5a4f081f563439f0bfe57026cb4fa99 Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Wed, 20 Nov 2024 19:20:43 +1100 Subject: [PATCH] Add TREE_GAP constant --- .../github/mrpowers/spark/fast/tests/SchemaComparer.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/scala/com/github/mrpowers/spark/fast/tests/SchemaComparer.scala b/core/src/main/scala/com/github/mrpowers/spark/fast/tests/SchemaComparer.scala index bd3aa09..32ceaf7 100644 --- a/core/src/main/scala/com/github/mrpowers/spark/fast/tests/SchemaComparer.scala +++ b/core/src/main/scala/com/github/mrpowers/spark/fast/tests/SchemaComparer.scala @@ -9,6 +9,7 @@ import org.apache.spark.sql.types._ object SchemaComparer { private val INDENT_GAP = 5 private val DESCRIPTION_GAP = 21 + private val TREE_GAP = 6 case class DatasetSchemaMismatch(smth: String) extends Exception(smth) private def betterSchemaMismatchMessage(actualSchema: StructType, expectedSchema: StructType): String = { showProductDiff( @@ -34,7 +35,6 @@ object SchemaComparer { } def depthToIndentStr(depth: Int): String = Range(0, depth).map(_ => "| ").mkString + "|--" - val treeSpaces = 6 val (treeFieldPair1, tree1MaxWidth) = flattenStrucType(actualSchema, 0) val (treeFieldPair2, _) = flattenStrucType(expectedSchema, 0) val (treePair, maxWidth) = treeFieldPair1 @@ -89,8 +89,8 @@ object SchemaComparer { (acc :+ pair, math.max(maxWidth, pair._1.length)) } - val schemaGap = maxWidth + treeSpaces - val headerGap = tree1MaxWidth + treeSpaces + val schemaGap = maxWidth + TREE_GAP + val headerGap = tree1MaxWidth + TREE_GAP treePair .foldLeft(new StringBuilder("\nActual Schema".padTo(headerGap, ' ') + "Expected Schema\n")) { case (sb, (s1, s2)) => val gap = if (s1.isEmpty) headerGap else schemaGap