xiarixiaoyao commented on code in PR #7333:
URL: https://github.com/apache/hudi/pull/7333#discussion_r1036860514


##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestAlterTable.scala:
##########
@@ -168,6 +169,56 @@ class TestAlterTable extends HoodieSparkSqlTestBase {
     }
   }
 
+  test("Test Enable and Disable Schema on read") {
+    withTempDir { tmp =>
+      val tableName = generateTableName
+      val tablePath = s"${tmp.getCanonicalPath}/$tableName"
+      // Create table
+      spark.sql(
+        s"""
+           |create table $tableName (
+           |  id int,
+           |  name string,
+           |  price double,
+           |  ts long
+           |) using hudi
+           | location '$tablePath'
+           | tblproperties (
+           |  type = 'cow',
+           |  primaryKey = 'id',
+           |  preCombineField = 'ts'
+           | )
+       """.stripMargin)
+
+      // Insert data to the new table.
+      spark.sql(s"insert into $tableName values(1, 'a1', 10, 1000)")
+      checkAnswer(s"select id, name, price, ts from $tableName")(
+        Seq(1, "a1", 10.0, 1000)
+      )
+
+      // add column
+      spark.sql(s"alter table $tableName add columns(new_col string)")

Review Comment:
   alter  command cannot  trigger schema  evolution.
   if  we  want to   use  sql command  to  do  schema evolution,  we need
   1)  spark.sql("set hoodie.schema.on.read.enable=true")
   2)  HoodieSparkUtils.gteqSpark3_1
   
   BTW, pls mv  those codes to  org.apache.spark.sql.hudi.TestSpark3DDL  thanks



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

Reply via email to