XuQianJin-Stars commented on code in PR #5620:
URL: https://github.com/apache/hudi/pull/5620#discussion_r875842983
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/procedure/TestCompactionProcedure.scala:
##########
@@ -48,22 +48,48 @@ class TestCompactionProcedure extends
HoodieSparkSqlTestBase {
spark.sql(s"insert into $tableName values(4, 'a4', 10, 1000)")
spark.sql(s"update $tableName set price = 11 where id = 1")
- spark.sql(s"call run_compaction(op => 'schedule', table =>
'$tableName')")
+ // Schedule the first compaction
+ val firstResult = spark.sql(s"call run_compaction(op => 'schedule',
table => '$tableName')")
+ .collect()
+ .map(row => Seq(row.getString(0), row.getInt(1), row.getString(2)))
+
spark.sql(s"update $tableName set price = 12 where id = 2")
- spark.sql(s"call run_compaction('schedule', '$tableName')")
- val compactionRows = spark.sql(s"call show_compaction(table =>
'$tableName', limit => 10)").collect()
- val timestamps = compactionRows.map(_.getString(0))
+
+ // Schedule the second compaction
+ val secondResult = spark.sql(s"call run_compaction('schedule',
'$tableName')")
+ .collect()
+ .map(row => Seq(row.getString(0), row.getInt(1), row.getString(2)))
+
+ assertResult(1)(firstResult.length)
+ assertResult(1)(secondResult.length)
+ val showCompactionSql: String = s"call show_compaction(table =>
'$tableName', limit => 10)"
+ checkAnswer(showCompactionSql)(
+ firstResult(0),
+ secondResult(0)
+ )
+
+ val compactionRows = spark.sql(showCompactionSql).collect()
+ val timestamps = compactionRows.map(_.getString(0)).sorted
assertResult(2)(timestamps.length)
- spark.sql(s"call run_compaction(op => 'run', table => '$tableName',
timestamp => ${timestamps(1)})")
+ // Execute the second scheduled compaction instant actually
+ spark.sql(s"call run_compaction(op => 'run', table => '$tableName',
timestamp => ${timestamps(1)})").show()
Review Comment:
Ditto
--
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]