srielau commented on code in PR #46267:
URL: https://github.com/apache/spark/pull/46267#discussion_r1595711075


##########
sql/core/src/test/resources/sql-tests/results/view-schema-binding.sql.out:
##########
@@ -0,0 +1,3081 @@
+-- Automatically generated by SQLQueryTestSuite
+-- !query
+SET spark.sql.ansi.enabled = true
+-- !query schema
+struct<key:string,value:string>
+-- !query output
+spark.sql.ansi.enabled true
+
+
+-- !query
+SET spark.sql.viewSchemaBindingMode
+-- !query schema
+struct<key:string,value:string>
+-- !query output
+spark.sql.viewSchemaBindingMode        COMPENSATION
+
+
+-- !query
+SET spark.sql.viewSchemaBindingMode = DISABLED
+-- !query schema
+struct<key:string,value:string>
+-- !query output
+spark.sql.viewSchemaBindingMode        DISABLED
+
+
+-- !query
+CREATE OR REPLACE VIEW v WITH SCHEMA BINDING AS SELECT 1
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.catalyst.parser.ParseException
+{
+  "errorClass" : "FEATURE_NOT_ENABLED",
+  "sqlState" : "56038",
+  "messageParameters" : {
+    "configKey" : "spark.sql.viewSchemaBindingMode",
+    "configValue" : "COMPENSATION",
+    "featureName" : "VIEW ... WITH SCHEMA ..."
+  },
+  "queryContext" : [ {
+    "objectType" : "",
+    "objectName" : "",
+    "startIndex" : 26,
+    "stopIndex" : 44,
+    "fragment" : "WITH SCHEMA BINDING"
+  } ]
+}
+
+
+-- !query
+CREATE OR REPLACE VIEW v WITH SCHEMA COMPENSATION AS SELECT 1
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.catalyst.parser.ParseException
+{
+  "errorClass" : "FEATURE_NOT_ENABLED",
+  "sqlState" : "56038",
+  "messageParameters" : {
+    "configKey" : "spark.sql.viewSchemaBindingMode",
+    "configValue" : "COMPENSATION",
+    "featureName" : "VIEW ... WITH SCHEMA ..."
+  },
+  "queryContext" : [ {
+    "objectType" : "",
+    "objectName" : "",
+    "startIndex" : 26,
+    "stopIndex" : 49,
+    "fragment" : "WITH SCHEMA COMPENSATION"
+  } ]
+}
+
+
+-- !query
+CREATE OR REPLACE VIEW v WITH SCHEMA TYPE EVOLUTION AS SELECT 1
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.catalyst.parser.ParseException
+{
+  "errorClass" : "FEATURE_NOT_ENABLED",
+  "sqlState" : "56038",
+  "messageParameters" : {
+    "configKey" : "spark.sql.viewSchemaBindingMode",
+    "configValue" : "COMPENSATION",
+    "featureName" : "VIEW ... WITH SCHEMA ..."
+  },
+  "queryContext" : [ {
+    "objectType" : "",
+    "objectName" : "",
+    "startIndex" : 26,
+    "stopIndex" : 51,
+    "fragment" : "WITH SCHEMA TYPE EVOLUTION"
+  } ]
+}
+
+
+-- !query
+CREATE OR REPLACE VIEW v WITH SCHEMA EVOLUTION AS SELECT 1
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.catalyst.parser.ParseException
+{
+  "errorClass" : "FEATURE_NOT_ENABLED",
+  "sqlState" : "56038",
+  "messageParameters" : {
+    "configKey" : "spark.sql.viewSchemaBindingMode",
+    "configValue" : "COMPENSATION",
+    "featureName" : "VIEW ... WITH SCHEMA ..."
+  },
+  "queryContext" : [ {
+    "objectType" : "",
+    "objectName" : "",
+    "startIndex" : 26,
+    "stopIndex" : 46,
+    "fragment" : "WITH SCHEMA EVOLUTION"
+  } ]
+}
+
+
+-- !query
+CREATE OR REPLACE VIEW v AS SELECT 1
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DESCRIBE EXTENDED v
+-- !query schema
+struct<col_name:string,data_type:string,comment:string>
+-- !query output
+1                      int                                         
+                                                                   
+# Detailed Table Information                                               
+Catalog                spark_catalog                               
+Database               default                                     
+Table                  v                                           
+Created Time [not included in comparison]
+Last Access [not included in comparison]
+Created By [not included in comparison]
+Type                   VIEW                                        
+View Text              SELECT 1                                    
+View Original Text     SELECT 1                                    
+View Catalog and Namespace     spark_catalog.default                       
+View Query Output Columns      [1]
+
+
+-- !query
+SHOW TABLE EXTENDED LIKE 'v'
+-- !query schema
+struct<namespace:string,tableName:string,isTemporary:boolean,information:string>
+-- !query output
+default        v       false   Catalog: spark_catalog
+Database: default
+Table: v
+Created Time [not included in comparison]
+Last Access [not included in comparison]
+Created By [not included in comparison]
+Type: VIEW
+View Text: SELECT 1
+View Original Text: SELECT 1
+View Catalog and Namespace: spark_catalog.default
+View Query Output Columns: [1]
+Schema: root
+ |-- 1: integer (nullable = false)
+
+
+-- !query
+DROP VIEW IF EXISTS v
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE OR REPLACE TEMPORARY VIEW v AS SELECT 1
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DESCRIBE EXTENDED v
+-- !query schema
+struct<col_name:string,data_type:string,comment:string>
+-- !query output
+1                      int
+
+
+-- !query
+SHOW TABLE EXTENDED LIKE 'v'
+-- !query schema
+struct<namespace:string,tableName:string,isTemporary:boolean,information:string>
+-- !query output
+       v       true    Table: v
+Created Time [not included in comparison]
+Last Access [not included in comparison]
+Created By [not included in comparison]
+Type: VIEW
+View Text: SELECT 1
+View Catalog and Namespace: spark_catalog.default
+View Query Output Columns: [1]
+Schema: root
+ |-- 1: integer (nullable = false)
+
+
+-- !query
+DROP VIEW IF EXISTS v
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP TABLE IF EXISTS t
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE t(c1 INT NOT NULL) USING PARQUET
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE OR REPLACE VIEW v AS SELECT * FROM t
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SELECT * FROM v
+-- !query schema
+struct<c1:int>
+-- !query output
+
+
+
+-- !query
+DESCRIBE EXTENDED v
+-- !query schema
+struct<col_name:string,data_type:string,comment:string>
+-- !query output
+c1                     int                                         
+                                                                   
+# Detailed Table Information                                               
+Catalog                spark_catalog                               
+Database               default                                     
+Table                  v                                           
+Created Time [not included in comparison]
+Last Access [not included in comparison]
+Created By [not included in comparison]
+Type                   VIEW                                        
+View Text              SELECT * FROM t                             
+View Original Text     SELECT * FROM t                             
+View Catalog and Namespace     spark_catalog.default                       
+View Query Output Columns      [c1]
+
+
+-- !query
+DROP TABLE IF EXISTS t
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE t(c1 BIGINT NOT NULL) USING PARQUET
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SELECT * FROM v
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+{
+  "errorClass" : "CANNOT_UP_CAST_DATATYPE",
+  "sqlState" : "42846",
+  "messageParameters" : {
+    "details" : "The type path of the target object is:\n\nYou can either add 
an explicit cast to the input data or choose a higher precision type of the 
field in the target object",
+    "expression" : "spark_catalog.default.t.c1",
+    "sourceType" : "\"BIGINT\"",
+    "targetType" : "\"INT\""
+  }
+}
+
+
+-- !query
+DESCRIBE EXTENDED v
+-- !query schema
+struct<col_name:string,data_type:string,comment:string>
+-- !query output
+c1                     int                                         
+                                                                   
+# Detailed Table Information                                               
+Catalog                spark_catalog                               
+Database               default                                     
+Table                  v                                           
+Created Time [not included in comparison]
+Last Access [not included in comparison]
+Created By [not included in comparison]
+Type                   VIEW                                        
+View Text              SELECT * FROM t                             
+View Original Text     SELECT * FROM t                             
+View Catalog and Namespace     spark_catalog.default                       
+View Query Output Columns      [c1]
+
+
+-- !query
+SET spark.sql.viewSchemaBindingMode = COMPENSATION
+-- !query schema
+struct<key:string,value:string>
+-- !query output
+spark.sql.viewSchemaBindingMode        COMPENSATION
+
+
+-- !query
+DROP TABLE IF EXISTS t
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE t(c1 INT NOT NULL) USING PARQUET
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE OR REPLACE VIEW v WITH SCHEMA BINDING AS SELECT * FROM t
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SELECT * FROM v
+-- !query schema
+struct<c1:int>
+-- !query output
+
+
+
+-- !query
+DESCRIBE EXTENDED v
+-- !query schema
+struct<col_name:string,data_type:string,comment:string>
+-- !query output
+c1                     int                                         
+                                                                   
+# Detailed Table Information                                               
+Catalog                spark_catalog                               
+Database               default                                     
+Table                  v                                           
+Created Time [not included in comparison]
+Last Access [not included in comparison]
+Created By [not included in comparison]
+Type                   VIEW                                        
+View Text              SELECT * FROM t                             
+View Original Text     SELECT * FROM t                             
+View Schema Mode       BINDING                                     
+View Catalog and Namespace     spark_catalog.default                       
+View Query Output Columns      [c1]
+
+
+-- !query
+DROP TABLE t
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE t(c1 BIGINT NOT NULL) USING PARQUET
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SELECT * FROM v
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+{
+  "errorClass" : "CANNOT_UP_CAST_DATATYPE",
+  "sqlState" : "42846",
+  "messageParameters" : {
+    "details" : "The type path of the target object is:\n\nYou can either add 
an explicit cast to the input data or choose a higher precision type of the 
field in the target object",
+    "expression" : "spark_catalog.default.t.c1",
+    "sourceType" : "\"BIGINT\"",
+    "targetType" : "\"INT\""
+  }
+}
+
+
+-- !query
+DESCRIBE EXTENDED v
+-- !query schema
+struct<col_name:string,data_type:string,comment:string>
+-- !query output
+c1                     int                                         
+                                                                   
+# Detailed Table Information                                               
+Catalog                spark_catalog                               
+Database               default                                     
+Table                  v                                           
+Created Time [not included in comparison]
+Last Access [not included in comparison]
+Created By [not included in comparison]
+Type                   VIEW                                        
+View Text              SELECT * FROM t                             
+View Original Text     SELECT * FROM t                             
+View Schema Mode       BINDING                                     
+View Catalog and Namespace     spark_catalog.default                       
+View Query Output Columns      [c1]
+
+
+-- !query
+DROP TABLE IF EXISTS t
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE t(c1 INT, c2 INT) USING PARQUET
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE OR REPLACE VIEW v WITH SCHEMA BINDING AS SELECT * FROM t
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SELECT * FROM v
+-- !query schema
+struct<c1:int,c2:int>
+-- !query output
+
+
+
+-- !query
+DESCRIBE EXTENDED v
+-- !query schema
+struct<col_name:string,data_type:string,comment:string>
+-- !query output
+c1                     int                                         
+c2                     int                                         
+                                                                   
+# Detailed Table Information                                               
+Catalog                spark_catalog                               
+Database               default                                     
+Table                  v                                           
+Created Time [not included in comparison]
+Last Access [not included in comparison]
+Created By [not included in comparison]
+Type                   VIEW                                        
+View Text              SELECT * FROM t                             
+View Original Text     SELECT * FROM t                             
+View Schema Mode       BINDING                                     
+View Catalog and Namespace     spark_catalog.default                       
+View Query Output Columns      [c1, c2]
+
+
+-- !query
+DROP TABLE t
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE TABLE t(c1 INT) USING PARQUET
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SELECT * FROM v
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+{
+  "errorClass" : "INCOMPATIBLE_VIEW_SCHEMA_CHANGE",
+  "sqlState" : "51024",
+  "messageParameters" : {
+    "actualCols" : "[]",
+    "colName" : "c2",
+    "expectedNum" : "1",
+    "suggestion" : "CREATE OR REPLACE VIEW spark_catalog.default.v AS SELECT * 
FROM t",
+    "viewName" : "`spark_catalog`.`default`.`v`"
+  }
+}
+
+
+-- !query
+DESCRIBE EXTENDED v
+-- !query schema
+struct<col_name:string,data_type:string,comment:string>
+-- !query output
+c1                     int                                         
+c2                     int                                         
+                                                                   
+# Detailed Table Information                                               
+Catalog                spark_catalog                               
+Database               default                                     
+Table                  v                                           
+Created Time [not included in comparison]
+Last Access [not included in comparison]
+Created By [not included in comparison]
+Type                   VIEW                                        
+View Text              SELECT * FROM t                             
+View Original Text     SELECT * FROM t                             
+View Schema Mode       BINDING                                     
+View Catalog and Namespace     spark_catalog.default                       
+View Query Output Columns      [c1, c2]
+
+
+-- !query
+SET spark.sql.viewSchemaBindingMode

Review Comment:
   Will rework the QA.



-- 
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

Reply via email to