geserdugarov commented on code in PR #11615:
URL: https://github.com/apache/hudi/pull/11615#discussion_r1675312608


##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestSparkSqlWithTimestampKeyGenerator.scala:
##########
@@ -99,6 +99,33 @@ class TestSparkSqlWithTimestampKeyGenerator extends 
HoodieSparkSqlTestBase {
       }
     }
   }
+
+  test("Test mandatory partitioning for timestamp key generator") {
+    withTempDir { tmp =>
+      spark.sql(
+        s"""
+           | CREATE TABLE should_fail (
+           |   id int,
+           |   name string,
+           |   precomb long,
+           |   ts long
+           | ) USING HUDI
+           | LOCATION '${tmp.getCanonicalPath + "/should_fail"}'
+           | TBLPROPERTIES (
+           |   type = 'COPY_ON_WRITE',
+           |   primaryKey = 'id',
+           |   preCombineField = 'precomb',
+           |   hoodie.table.keygenerator.class = 
'org.apache.hudi.keygen.TimestampBasedKeyGenerator',
+           |   ${timestampKeyGeneratorSettings.head}
+           | )
+           |""".stripMargin)
+      // should fail due to absent partitioning
+      assertThrows[HoodieException] {
+        spark.sql(s"INSERT INTO should_fail VALUES 
${dataBatchesWithLongOfSeconds(0)}")

Review Comment:
   Added check that `TimestampBasedKeyGenerator` doesn't work with 
non-partitioned table.



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to