This is an automated email from the ASF dual-hosted git repository.

LuciferYang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 73952f2ca4 [GLUTEN-13771][CH] Use the S3 storage policy in the S3 
insert-with-optimize test (#13772)
73952f2ca4 is described below

commit 73952f2ca4b1e11ad70bd5447721fa3a5d71c298
Author: Shivadarshan Devadiga <[email protected]>
AuthorDate: Wed Nov 25 17:27:39 2026 +0530

    [GLUTEN-13771][CH] Use the S3 storage policy in the S3 insert-with-optimize 
test (#13772)
    
    ## What changes are proposed in this pull request?
    
    `GlutenClickHouseMergeTreeWriteOnS3Suite`'s `test mergetree insert with 
optimize basic` sets `INSERT_WITHOUT_LOCAL_STORAGE`, but it doesn't test that 
setting:
    
    - Its table had no storage policy, so it used the `default` one. 
`SparkMergeTreeSink::create` only stages parts locally for a remote disk, so 
the setting had no effect.
    - Its assertion checked a local path without the suite's `_s3` suffix, 
which nothing writes, so it could never fail.
    
    This PR:
    - adds `TBLPROPERTIES (storage_policy='__s3_main')`, as the other 
catalog-table cases in the suite do, and as the HDFS suite's case of the same 
name does with `__hdfs_main`;
    - sets `MIN_INSERT_BLOCK_SIZE_ROWS` to 10000, as the HDFS case does, so 
that the insert writes several parts and the merge runs;
    - replaces the local-directory assertion and the `count(*)`, which Delta 
answers from the log's stats. The parts are now read back from S3 with 
`minioHelper.resetMeta()` and then `q1`, checking that the log has one merged 
part with all the rows;
    - checks the objects left on S3 in an `eventually` block: the commit and 
the three files of the merged part, plus the `_commits` directory on Spark 3.5. 
This is the counterpart of the HDFS case's `countDir` check;
    - removes the `java.io.File` import that only the old assertion used.
    
    ## How was this patch tested?
    
    `spotless:check` passes on the changed file. 
`GlutenClickHouseMergeTreeWriteOnS3Suite` is `@DoNotDiscover` (#11734) and 
needs MinIO, so the ClickHouse CI compiles it but doesn't run it.
    
    The expected object count is derived from the counts the suites already 
measure: the HDFS case's 4 for the same CTAS, and this suite's 6/5 for a 
two-commit table.
    
    ## Was this patch authored or co-authored using generative AI tooling?
    
    Co-authored by: Claude Sonnet 4.5
    
    
    Related issue: #13771
---
 .../GlutenClickHouseMergeTreeWriteOnS3Suite.scala  | 33 +++++++++++++++++-----
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/mergetree/GlutenClickHouseMergeTreeWriteOnS3Suite.scala
 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/mergetree/GlutenClickHouseMergeTreeWriteOnS3Suite.scala
index c87a0e2013..e5c49be39e 100644
--- 
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/mergetree/GlutenClickHouseMergeTreeWriteOnS3Suite.scala
+++ 
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/mergetree/GlutenClickHouseMergeTreeWriteOnS3Suite.scala
@@ -29,8 +29,6 @@ import 
org.apache.spark.sql.execution.datasources.v2.clickhouse.metadata.AddMerg
 
 import org.scalatest.DoNotDiscover
 
-import java.io.File
-
 import scala.concurrent.duration.DurationInt
 
 @DoNotDiscover
@@ -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)
+            // With MIN_INSERT_BLOCK_SIZE_ROWS at 10000 the insert writes 
several parts, which the
+            // merge combines into one, as in the HDFS suite.
+            assertResult(1)(parts.size)
+        }
+
+        // The merge deletes the parts it combined from S3. What remains is 
the log's commit
+        // and the three files of the merged part, and on Spark 3.5 the 
_commits directory.
+        eventually(timeout(60.seconds), interval(2.seconds)) {
+          val objectNames = minioHelper.listObjects(BUCKET_NAME, tableName)
+          assertResult(if (isSparkVersionGE("3.5")) 5 else 
4)(countObjects(objectNames.toSeq))
+        }
       }
     }
   }


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

Reply via email to