|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | +# |
| 20 | + |
| 21 | +# TPC-H benchmark using Iceberg tables with Comet's native iceberg-rust integration. |
| 22 | +# |
| 23 | +# Required environment variables: |
| 24 | +# SPARK_HOME - Path to Spark installation |
| 25 | +# SPARK_MASTER - Spark master URL (e.g., spark://localhost:7077) |
| 26 | +# COMET_JAR - Path to Comet JAR |
| 27 | +# ICEBERG_JAR - Path to Iceberg Spark runtime JAR |
| 28 | +# ICEBERG_WAREHOUSE - Path to Iceberg warehouse directory |
| 29 | +# TPCH_QUERIES - Path to TPC-H query files |
| 30 | +# |
| 31 | +# Optional: |
| 32 | +# ICEBERG_CATALOG - Catalog name (default: local) |
| 33 | +# ICEBERG_DATABASE - Database name (default: tpch) |
| 34 | +# |
| 35 | +# Setup (run once to create Iceberg tables from Parquet): |
| 36 | +# $SPARK_HOME/bin/spark-submit \ |
| 37 | +# --packages org.apache.iceberg:iceberg-spark-runtime-3.5_2.12:1.8.1 \ |
| 38 | +# --conf spark.sql.catalog.local=org.apache.iceberg.spark.SparkCatalog \ |
| 39 | +# --conf spark.sql.catalog.local.type=hadoop \ |
| 40 | +# --conf spark.sql.catalog.local.warehouse=$ICEBERG_WAREHOUSE \ |
| 41 | +# create-iceberg-tpch.py \ |
| 42 | +# --parquet-path $TPCH_DATA \ |
| 43 | +# --catalog local \ |
| 44 | +# --database tpch |
| 45 | + |
| 46 | +set -e |
| 47 | + |
| 48 | +# Defaults |
| 49 | +ICEBERG_CATALOG=${ICEBERG_CATALOG:-local} |
| 50 | +ICEBERG_DATABASE=${ICEBERG_DATABASE:-tpch} |
| 51 | + |
| 52 | +# Validate required variables |
| 53 | +if [ -z "$SPARK_HOME" ]; then |
| 54 | + echo "Error: SPARK_HOME is not set" |
| 55 | + exit 1 |
| 56 | +fi |
| 57 | +if [ -z "$COMET_JAR" ]; then |
| 58 | + echo "Error: COMET_JAR is not set" |
| 59 | + exit 1 |
| 60 | +fi |
| 61 | +if [ -z "$ICEBERG_JAR" ]; then |
| 62 | + echo "Error: ICEBERG_JAR is not set" |
| 63 | + echo "Download from: https://repo1.maven.org/maven2/org/apache/iceberg/iceberg-spark-runtime-3.5_2.12/1.8.1/" |
| 64 | + exit 1 |
| 65 | +fi |
| 66 | +if [ -z "$ICEBERG_WAREHOUSE" ]; then |
| 67 | + echo "Error: ICEBERG_WAREHOUSE is not set" |
| 68 | + exit 1 |
| 69 | +fi |
| 70 | +if [ -z "$TPCH_QUERIES" ]; then |
| 71 | + echo "Error: TPCH_QUERIES is not set" |
| 72 | + exit 1 |
| 73 | +fi |
| 74 | + |
| 75 | +$SPARK_HOME/sbin/stop-master.sh 2>/dev/null || true |
| 76 | +$SPARK_HOME/sbin/stop-worker.sh 2>/dev/null || true |
| 77 | + |
| 78 | +$SPARK_HOME/sbin/start-master.sh |
| 79 | +$SPARK_HOME/sbin/start-worker.sh $SPARK_MASTER |
| 80 | + |
| 81 | +$SPARK_HOME/bin/spark-submit \ |
| 82 | + --master $SPARK_MASTER \ |
| 83 | + --jars $COMET_JAR,$ICEBERG_JAR \ |
| 84 | + --driver-class-path $COMET_JAR:$ICEBERG_JAR \ |
| 85 | + --conf spark.driver.memory=8G \ |
| 86 | + --conf spark.executor.instances=1 \ |
| 87 | + --conf spark.executor.cores=8 \ |
| 88 | + --conf spark.cores.max=8 \ |
| 89 | + --conf spark.executor.memory=16g \ |
| 90 | + --conf spark.memory.offHeap.enabled=true \ |
| 91 | + --conf spark.memory.offHeap.size=16g \ |
| 92 | + --conf spark.eventLog.enabled=true \ |
| 93 | + --conf spark.driver.extraClassPath=$COMET_JAR:$ICEBERG_JAR \ |
| 94 | + --conf spark.executor.extraClassPath=$COMET_JAR:$ICEBERG_JAR \ |
| 95 | + --conf spark.plugins=org.apache.spark.CometPlugin \ |
| 96 | + --conf spark.shuffle.manager=org.apache.spark.sql.comet.execution.shuffle.CometShuffleManager \ |
| 97 | + --conf spark.comet.exec.replaceSortMergeJoin=true \ |
| 98 | + --conf spark.comet.expression.Cast.allowIncompatible=true \ |
| 99 | + --conf spark.comet.enabled=true \ |
| 100 | + --conf spark.comet.exec.enabled=true \ |
| 101 | + --conf spark.comet.scan.icebergNative.enabled=true \ |
| 102 | + --conf spark.comet.explainFallback.enabled=true \ |
| 103 | + --conf spark.sql.catalog.${ICEBERG_CATALOG}=org.apache.iceberg.spark.SparkCatalog \ |
| 104 | + --conf spark.sql.catalog.${ICEBERG_CATALOG}.type=hadoop \ |
| 105 | + --conf spark.sql.catalog.${ICEBERG_CATALOG}.warehouse=$ICEBERG_WAREHOUSE \ |
| 106 | + --conf spark.sql.defaultCatalog=${ICEBERG_CATALOG} \ |
| 107 | + tpcbench.py \ |
| 108 | + --name comet-iceberg \ |
| 109 | + --benchmark tpch \ |
| 110 | + --catalog $ICEBERG_CATALOG \ |
| 111 | + --database $ICEBERG_DATABASE \ |
| 112 | + --queries $TPCH_QUERIES \ |
| 113 | + --output . \ |
| 114 | + --iterations 1 |
0 commit comments