-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Spark] Reject unsupported type changes with Uniform #3947
Changes from 1 commit
6b2a0ee
ba65061
8cc235e
783af1b
51e83c7
3a48dc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,35 @@ | ||||||
package org.apache.spark.sql.delta | ||||||
|
||||||
import org.apache.spark.sql.types.AtomicType | ||||||
|
||||||
/** | ||||||
* A type widening mode captures a specific set of type changes that are allowed to be applied. | ||||||
* Currently: | ||||||
* - NoTypeWidening: No type change is allowed. | ||||||
* - TypeEvolution(uniformIcebergEnabled = true): Type changes that are eligible to be applied | ||||||
* automatically during schema evolution and that are supported by Iceberg are allowed. | ||||||
* - TypeEvolution(uniformIcebergEnabled = false): Type changes that are eligible to be applied | ||||||
* automatically during schema evolution are allowed, even if they are not supported by Iceberg. | ||||||
*/ | ||||||
trait TypeWideningMode { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think it makes sense to enforce exhaustiveness here. There shouldn't be other places that need to specify customs rules, I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||||||
def shouldWidenType(fromType: AtomicType, toType: AtomicType): Boolean | ||||||
} | ||||||
|
||||||
object TypeWideningMode { | ||||||
/** | ||||||
* No type change allowed. Typically because type widening and/or schema evolution isn't enabled. | ||||||
*/ | ||||||
object NoTypeWidening extends TypeWideningMode { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Just so it looks like a nice enum-like thingy ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||||||
override def shouldWidenType(fromType: AtomicType, toType: AtomicType): Boolean = false | ||||||
} | ||||||
|
||||||
/** | ||||||
* Type changes that are eligible to be applied automatically during schema evolution are allowed. | ||||||
* Can be restricted to only type changes supported by Iceberg. | ||||||
*/ | ||||||
case class TypeEvolution(uniformIcebergEnabled: Boolean) extends TypeWideningMode { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, that fits better |
||||||
override def shouldWidenType(fromType: AtomicType, toType: AtomicType): Boolean = | ||||||
TypeWidening.isTypeChangeSupportedForSchemaEvolution( | ||||||
fromType = fromType, toType = toType, uniformIcebergEnabled) | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a bug present in the initial allowTypeWidening method: the mergeSchema option value wasn't correctly taken into account