LuciferYang commented on code in PR #13772:
URL: https://github.com/apache/gluten/pull/13772#discussion_r4691089383


##########
backends-clickhouse/src/test/scala/org/apache/gluten/execution/mergetree/GlutenClickHouseMergeTreeWriteOnS3Suite.scala:
##########
@@ -501,20 +499,41 @@ class GlutenClickHouseMergeTreeWriteOnS3Suite extends 
CreateMergeTreeSuite {
     withSQLConf(
       "spark.databricks.delta.optimize.minFileSize" -> "200000000",
       RuntimeSettings.INSERT_WITHOUT_LOCAL_STORAGE.key -> "true",
-      RuntimeSettings.MERGE_AFTER_INSERT.key -> "true"
+      RuntimeSettings.MERGE_AFTER_INSERT.key -> "true",
+      RuntimeSettings.MIN_INSERT_BLOCK_SIZE_ROWS.key -> "10000"
     ) {
       withTable(tableName) {
         spark.sql(s"""
                      |CREATE TABLE $tableName
                      |USING clickhouse
                      |LOCATION '$dataPath'
+                     |TBLPROPERTIES (storage_policy='__s3_main')
                      | as select * from lineitem
                      |""".stripMargin)
 
-        val ret = spark.sql(s"select count(*) from $tableName").collect()
-        assertResult(600572)(ret.apply(0).get(0))
-        assert(
-          !new 
File(s"$CH_DEFAULT_STORAGE_DIR/lineitem_mergetree_insert_optimize_basic").exists())
+        // Read the parts back from S3, not from the part metadata the write 
left on local disk.
+        minioHelper.resetMeta()
+        customCheckQuery(q1(tableName)) {
+          df =>
+            val scanExec = collect(df.queryExecution.executedPlan) {
+              case f: FileSourceScanExecTransformer => f
+            }
+            assertResult(1)(scanExec.size)
+            val fileIndex = 
scanExec.head.relation.location.asInstanceOf[TahoeFileIndex]
+            val parts =
+              fileIndex.matchingFiles(Nil, Nil).map(f => 
f.asInstanceOf[AddMergeTreeParts])
+            assertResult(600572)(parts.map(_.rows).sum)
+            // The insert writes a part per block of 10000 rows, which the 
merge combines into

Review Comment:
   nit: the insert doesn't write one part per 10000 rows. 
`MIN_INSERT_BLOCK_SIZE_ROWS` is the threshold `Squashing` uses in 
`SparkMergeTreeSink::consume`, so a part is cut once the scan blocks collected 
so far reach 10000 rows, and the part sizes follow the scan's block size. Maybe 
something like: "With `MIN_INSERT_BLOCK_SIZE_ROWS` at 10000 the insert writes 
several parts, which the merge combines into one, as in the HDFS suite."



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to