bryanck commented on code in PR #17838:
URL: https://github.com/apache/iceberg/pull/17838#discussion_r3874213681
##########
spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveViews.scala:
##########
@@ -111,16 +113,42 @@ case class ResolveViews(spark: SparkSession) extends
Rule[LogicalPlan] with Look
// Apply the field aliases and column comments
// This logic differs from how Spark handles views in
SessionCatalog.fromCatalogTable.
- // This is more strict because it doesn't allow resolution by field name.
+ // BINDING is more strict because it doesn't allow resolution by field
name.
+ val compensate = viewSchemaMode ==
SparkSQLProperties.VIEW_SCHEMA_MODE_COMPENSATION
val aliases = view.schema.fields.zipWithIndex.map { case (expected, pos) =>
val attr = GetColumnByOrdinal(pos, expected.dataType)
- Alias(UpCast(attr, expected.dataType), expected.name)(explicitMetadata =
- Some(expected.metadata))
+ val cast = if (compensate) {
+ Cast(attr, expected.dataType, ansiEnabled = true)
+ } else {
+ UpCast(attr, expected.dataType)
+ }
+ Alias(cast, expected.name)(explicitMetadata = Some(expected.metadata))
Review Comment:
Type evolution has much bigger scope, so the thought here is to start with
compensation mode and follow up with additional support as needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]