Skip to content

Commit 5637683

Browse files
committed
Cleanup
1 parent c3f04d6 commit 5637683

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSchemaEvolution.scala

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,25 @@ object ResolveSchemaEvolution extends Rule[LogicalPlan] {
130130

131131
case (ArrayType(currentElementType, _), ArrayType(newElementType, _)) =>
132132
computeSchemaChanges(
133-
currentElementType, newElementType,
134-
fieldPath :+ "element", isByName, error)
133+
currentElementType,
134+
newElementType,
135+
fieldPath :+ "element",
136+
isByName,
137+
error)
135138

136139
case (MapType(currentKeyType, currentValueType, _), MapType(newKeyType, newValueType, _)) =>
137140
val keyChanges = computeSchemaChanges(
138-
currentKeyType, newKeyType,
139-
fieldPath :+ "key", isByName, error)
141+
currentKeyType,
142+
newKeyType,
143+
fieldPath :+ "key",
144+
isByName,
145+
error)
140146
val valueChanges = computeSchemaChanges(
141-
currentValueType, newValueType,
142-
fieldPath :+ "value", isByName, error)
147+
currentValueType,
148+
newValueType,
149+
fieldPath :+ "value",
150+
isByName,
151+
error)
143152
keyChanges ++ valueChanges
144153

145154
case (currentType: AtomicType, newType: AtomicType) if currentType != newType =>
@@ -163,7 +172,7 @@ object ResolveSchemaEvolution extends Rule[LogicalPlan] {
163172
currentFields: Array[StructField],
164173
newFields: Array[StructField],
165174
fieldPath: List[String],
166-
onIncompatible: => Nothing): Array[TableChange] = {
175+
error: => Nothing): Array[TableChange] = {
167176
val currentFieldMap = toFieldMap(currentFields)
168177
val newFieldMap = toFieldMap(newFields)
169178

@@ -172,8 +181,11 @@ object ResolveSchemaEvolution extends Rule[LogicalPlan] {
172181
.filter(f => newFieldMap.contains(f.name))
173182
.flatMap { f =>
174183
computeSchemaChanges(
175-
f.dataType, newFieldMap(f.name).dataType,
176-
fieldPath :+ f.name, isByName = true, onIncompatible)
184+
f.dataType,
185+
newFieldMap(f.name).dataType,
186+
fieldPath :+ f.name,
187+
isByName = true,
188+
error)
177189
}
178190

179191
// Collect newly added fields
@@ -192,12 +204,15 @@ object ResolveSchemaEvolution extends Rule[LogicalPlan] {
192204
currentFields: Array[StructField],
193205
newFields: Array[StructField],
194206
fieldPath: List[String],
195-
onIncompatible: => Nothing): Array[TableChange] = {
207+
error: => Nothing): Array[TableChange] = {
196208
// Update existing field types by pairing fields at the same position.
197209
val updates = currentFields.zip(newFields).flatMap { case (currentField, newField) =>
198210
computeSchemaChanges(
199-
currentField.dataType, newField.dataType,
200-
fieldPath :+ currentField.name, isByName = false, onIncompatible)
211+
currentField.dataType,
212+
newField.dataType,
213+
fieldPath :+ currentField.name,
214+
isByName = false,
215+
error)
201216
}
202217

203218
// Extra source fields beyond the target's field count are new additions.

0 commit comments

Comments
 (0)