singhpk234 commented on code in PR #17838:
URL: https://github.com/apache/iceberg/pull/17838#discussion_r3874086842
##########
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:
[doubt] why didn't we add the full view schema compatibilty which spark
supports ?
https://github.com/apache/spark/pull/46267/changes#diff-9dd0899e5406230aeff96654432da54f35255f6dc60eecb87264a5c508a8c826R930
--
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]