|
| 1 | +<!--- |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, |
| 13 | + software distributed under the License is distributed on an |
| 14 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + KIND, either express or implied. See the License for the |
| 16 | + specific language governing permissions and limitations |
| 17 | + under the License. |
| 18 | +--> |
| 19 | + |
| 20 | +# Running Delta Lake Tests with Comet |
| 21 | + |
| 22 | +## Comet's own Delta test suite |
| 23 | + |
| 24 | +The primary test suite is `CometDeltaNativeSuite` with 34 test cases covering: |
| 25 | + |
| 26 | +- Basic reads (unpartitioned, multi-file, partitioned, multi-column partition) |
| 27 | +- Projection pushdown, filter pushdown, predicate variety |
| 28 | +- Complex types (arrays, maps, structs, deeply nested) |
| 29 | +- Schema evolution, time travel (version + timestamp) |
| 30 | +- Deletion vectors (pre-DELETE acceleration + post-DELETE native DV filter) |
| 31 | +- Column mapping (id mode, name mode, rename) |
| 32 | +- Aggregation, joins, window functions, UNION, DISTINCT |
| 33 | +- NULL handling, case insensitivity, ORDER BY + LIMIT |
| 34 | + |
| 35 | +### Running the suite |
| 36 | + |
| 37 | +```bash |
| 38 | +# Build native library first |
| 39 | +cd native && cargo build && cd .. |
| 40 | + |
| 41 | +# Run the Delta suite |
| 42 | +./mvnw -Pspark-3.5 -pl spark -am test \ |
| 43 | + -Dsuites=org.apache.comet.CometDeltaNativeSuite \ |
| 44 | + -Dmaven.gitcommitid.skip |
| 45 | +``` |
| 46 | + |
| 47 | +### Test dependencies |
| 48 | + |
| 49 | +Delta tests require `io.delta:delta-spark_2.12:3.3.2` which is added as a |
| 50 | +test-scope dependency in `spark/pom.xml` under the `spark-3.5` profile. The |
| 51 | +dependency excludes Spark and Hadoop transitives so Comet's pinned versions |
| 52 | +stay authoritative. |
| 53 | + |
| 54 | +### Test harness notes |
| 55 | + |
| 56 | +The Delta test suite disables Spark's `DebugFilesystem` and Delta's test-only |
| 57 | +filename prefixes (`test%file%prefix-`, `test%dv%prefix-`) because |
| 58 | +delta-kernel-rs reads files by the names recorded in the transaction log, which |
| 59 | +don't include Spark/Delta's test prefixes. Production users are unaffected. |
| 60 | + |
| 61 | +The suite also sets `spark.databricks.delta.deletionVectors.useMetadataRowIndex=false` |
| 62 | +to use Delta's older DV read strategy that inserts a `Project -> Filter` subtree |
| 63 | +(which Comet's plan rewrite can detect and strip), rather than the default |
| 64 | +metadata-row-index strategy that's opaque to plan-level rewriting. |
| 65 | + |
| 66 | +## Benchmarks |
| 67 | + |
| 68 | +### Micro-benchmark |
| 69 | + |
| 70 | +```bash |
| 71 | +SPARK_GENERATE_BENCHMARK_FILES=1 make \ |
| 72 | + benchmark-org.apache.spark.sql.benchmark.CometDeltaReadBenchmark |
| 73 | +``` |
| 74 | + |
| 75 | +Results are written to `spark/benchmarks/CometDeltaReadBenchmark-results.txt`. |
| 76 | + |
| 77 | +### TPC-DS / TPC-H |
| 78 | + |
| 79 | +1. Convert Parquet data to Delta: |
| 80 | + |
| 81 | +```bash |
| 82 | +spark-submit \ |
| 83 | + --packages io.delta:delta-spark_2.12:3.3.2 \ |
| 84 | + --conf spark.sql.extensions=io.delta.sql.DeltaSparkSessionExtension \ |
| 85 | + --conf spark.sql.catalog.spark_catalog=org.apache.spark.sql.delta.catalog.DeltaCatalog \ |
| 86 | + benchmarks/tpc/create-delta-tables.py \ |
| 87 | + --benchmark tpcds \ |
| 88 | + --parquet-path /data/tpcds \ |
| 89 | + --warehouse /data/delta-tpcds |
| 90 | +``` |
| 91 | + |
| 92 | +2. Run the benchmark: |
| 93 | + |
| 94 | +```bash |
| 95 | +DELTA_JAR=/path/to/delta-spark.jar \ |
| 96 | +COMET_JAR=/path/to/comet-spark.jar \ |
| 97 | +DELTA_WAREHOUSE=/data/delta-tpcds \ |
| 98 | +python benchmarks/tpc/tpcbench.py \ |
| 99 | + --engine comet-delta \ |
| 100 | + --benchmark tpcds |
| 101 | +``` |
| 102 | + |
| 103 | +Engine configs are in `benchmarks/tpc/engines/comet-delta.toml` and |
| 104 | +`benchmarks/tpc/engines/comet-delta-hashjoin.toml`. |
| 105 | + |
| 106 | +## TPC-DS Plan Stability Fixtures |
| 107 | + |
| 108 | +To generate the `q*.native_delta_compat/` plan stability golden files: |
| 109 | + |
| 110 | +1. Add `CometConf.SCAN_NATIVE_DELTA_COMPAT` to the `scanImpls` list in |
| 111 | + `CometPlanStabilitySuite.scala` (line 66). |
| 112 | + |
| 113 | +2. Ensure TPC-DS data exists as Delta tables (see `create-delta-tables.py` |
| 114 | + in the Benchmarks section above). |
| 115 | + |
| 116 | +3. Generate golden files: |
| 117 | + |
| 118 | +```bash |
| 119 | +SPARK_GENERATE_GOLDEN_FILES=1 ./mvnw -pl spark \ |
| 120 | + -Dsuites=org.apache.spark.sql.comet.CometTPCDSV1_4_PlanStabilitySuite \ |
| 121 | + test -Pspark-3.5 -Dmaven.gitcommitid.skip |
| 122 | +``` |
| 123 | + |
| 124 | +4. Commit the generated `q*.native_delta_compat/extended.txt` files under |
| 125 | + `spark/src/test/resources/tpcds-plan-stability/approved-plans-*`. |
0 commit comments