Yohahaha commented on code in PR #2437:
URL: https://github.com/apache/fluss/pull/2437#discussion_r2727085790
##########
fluss-spark/fluss-spark-ut/src/test/scala/org/apache/fluss/spark/SparkCatalogTest.scala:
##########
@@ -192,6 +197,46 @@ class SparkCatalogTest extends FlussSparkTestBase {
checkAnswer(sql("SHOW DATABASES"), Row(DEFAULT_DATABASE) :: Nil)
}
+ test("Catalog: set/remove table properties") {
+ withTable("t") {
+ sql(
+ s"CREATE TABLE $DEFAULT_DATABASE.t (id int, name string)
TBLPROPERTIES('key1' = 'value1', '${SparkConnectorOptions.BUCKET_NUMBER.key()}'
= 3)")
+ var flussTable = admin.getTableInfo(createTablePath("t")).get()
+ assertResult(
+ Map(ConfigOptions.TABLE_REPLICATION_FACTOR.key() -> "1"),
+ "check table properties")(flussTable.getProperties.toMap.asScala)
+ assert(
+ flussTable.getCustomProperties.toMap.asScala.getOrElse("key1",
"non-exists") == "value1")
+
+ sql("ALTER TABLE t SET TBLPROPERTIES('key1' = 'value2', 'key2' =
'value2')")
+ flussTable = admin.getTableInfo(createTablePath("t")).get()
+ assertResult(
+ Map(ConfigOptions.TABLE_REPLICATION_FACTOR.key() -> "1"),
+ "check table properties")(flussTable.getProperties.toMap.asScala)
+ assert(
+ flussTable.getCustomProperties.toMap.asScala.getOrElse("key1",
"non-exists") == "value2")
+ assert(
+ flussTable.getCustomProperties.toMap.asScala.getOrElse("key2",
"non-exists") == "value2")
+
+ sql("ALTER TABLE t UNSET TBLPROPERTIES('key1', 'key2')")
+ flussTable = admin.getTableInfo(createTablePath("t")).get()
+ assert(!flussTable.getCustomProperties.toMap.asScala.contains("key1"))
+ assert(!flussTable.getCustomProperties.toMap.asScala.contains("key2"))
+
+ sql("ALTER TABLE t UNSET TBLPROPERTIES('key1')")
+
+ // Most table properties with prefix of 'table.' are not allowed to be
modified.
+ intercept[ExecutionException] {
+ sql(
+ s"ALTER TABLE t SET
TBLPROPERTIES('${ConfigOptions.TABLE_REPLICATION_FACTOR.key()}' = '2')")
+ }.getCause.shouldBe(a[InvalidAlterTableException])
+ intercept[ExecutionException] {
+ sql(
+ s"ALTER TABLE t SET
TBLPROPERTIES('${ConfigOptions.TABLE_DATALAKE_FORMAT.key()}' = 'paimon')")
+ }.getCause.shouldBe(a[InvalidAlterTableException])
Review Comment:
I know, will test this behavior in lake catalog DDL pr.
--
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]