cloud-fan commented on code in PR #46267: URL: https://github.com/apache/spark/pull/46267#discussion_r1596861036
########## sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/rules.scala: ########## @@ -620,3 +621,65 @@ object CollationCheck extends (LogicalPlan => Unit) { private def isCollationExpression(expression: Expression): Boolean = expression.isInstanceOf[Collation] || expression.isInstanceOf[Collate] } + + +/** + * This rule checks for references to views WITH SCHEMA [TYPE] EVOLUTION and synchronizes the + * catalog if evolution was detected. + * It does so by walking the resolved plan looking for View operators for persisted views. + */ +object ViewSyncSchemaToMetaStore extends (LogicalPlan => Unit) { + def apply(plan: LogicalPlan): Unit = { + plan.foreach { + case View(metaData, false, viewQuery) + if (metaData.viewSchemaMode == SchemaTypeEvolution || + metaData.viewSchemaMode == SchemaEvolution) => + val viewSchemaMode = metaData.viewSchemaMode + val viewFields = metaData.schema.fields + val viewQueryFields = viewQuery.schema.fields + val session = SparkSession.getActiveSession.get + val redoSignature = + viewSchemaMode == SchemaEvolution && viewFields.length != viewQueryFields.length Review Comment: what happens if the number of columns doesn't change but the column names are all different? shall we still redo signature? -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org