Skip to content

Commit

Permalink
Add TREE_GAP constant
Browse files Browse the repository at this point in the history
  • Loading branch information
zeotuan committed Nov 20, 2024
1 parent b79adc4 commit 94a5f9c
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 94a5f9c

Please sign in to comment.