@@ -23,25 +23,29 @@ public class DataFrameSchemaImpl(override val columns: Map<String, ColumnSchema>
23
23
var result: CompareResult = Equals
24
24
25
25
// check for each column in this schema if there is a column with the same name in the other schema
26
- // - if so, those schemas for equality, taking comparisonMode into account
27
- // - if not, consider the other schema derived from this (or unrelated if comparisonMode == STRICT)
26
+ // - if so, check those schemas for equality, taking comparisonMode into account
27
+ // - if not, consider the other schema derived from this (or unrelated (None) if comparisonMode == STRICT)
28
28
this .columns.forEach { (thisColName, thisSchema) ->
29
29
val otherSchema = other.columns[thisColName]
30
30
result + = when {
31
31
otherSchema != null -> {
32
- val comparison = thisSchema.compare(
33
- other = otherSchema,
34
- comparisonMode = if (comparisonMode == STRICT_FOR_NESTED_SCHEMAS ) STRICT else comparisonMode,
35
- )
36
- if (comparison != Equals && comparisonMode == STRICT ) None else comparison
32
+ // increase comparisonMode strictness when dealing with nested schemas of FrameColumns or ColumnGroups
33
+ val newComparisonMode =
34
+ if (comparisonMode == STRICT_FOR_NESTED_SCHEMAS && thisSchema !is ColumnSchema .Value ) {
35
+ STRICT
36
+ } else {
37
+ comparisonMode
38
+ }
39
+
40
+ thisSchema.compare(other = otherSchema, comparisonMode = newComparisonMode)
37
41
}
38
42
39
43
else -> if (comparisonMode == STRICT ) None else IsDerived
40
44
}
41
45
if (result == None ) return None
42
46
}
43
47
// then check for each column in the other schema if there is a column with the same name in this schema
44
- // if not, consider the other schema as super to this (or unrelated if comparisonMode == STRICT)
48
+ // if not, consider the other schema as super to this (or unrelated (None) if comparisonMode == STRICT)
45
49
other.columns.forEach { (otherColName, _) ->
46
50
if (this .columns[otherColName] != null ) return @forEach
47
51
result + = if (comparisonMode == STRICT ) None else IsSuper
0 commit comments