@@ -67,18 +67,22 @@ RUN tar -xzv \
6767 tar -xzv \
6868 --exclude="apache-tez-$TEZ_VERSION-bin/share" \
6969 -f /opt/apache-tez-$TEZ_VERSION-bin.tar.gz \
70- -C /opt
70+ -C /opt; \
71+ mkdir -p /opt/tez-snapshot;
7172
7273FROM eclipse-temurin:21-jdk-ubi9-minimal AS run
7374
7475ARG UID=1000
7576ARG HADOOP_VERSION
7677ARG HIVE_VERSION
7778ARG TEZ_VERSION
79+ ARG TEZ_SNAPSHOT_VERSION=
80+ ARG TEZ_SNAPSHOT_REPO_URL=https://repository.apache.org/content/repositories/snapshots
81+
7882# Install dependencies
7983RUN set -ex; \
8084 microdnf update -y; \
81- microdnf -y install procps gettext; \
85+ microdnf -y install procps gettext wget xmlstarlet ; \
8286 microdnf clean all; \
8387 useradd --no-create-home -s /sbin/nologin -c "" --uid $UID hive
8488
@@ -93,6 +97,38 @@ ENV PATH=$HIVE_HOME/bin:$HADOOP_HOME/bin:$PATH
9397COPY --from=env --chown=hive /opt/hadoop-$HADOOP_VERSION $HADOOP_HOME
9498COPY --from=env --chown=hive /opt/apache-hive-$HIVE_VERSION-bin $HIVE_HOME
9599COPY --from=env --chown=hive /opt/apache-tez-$TEZ_VERSION-bin $TEZ_HOME
100+ COPY --from=env --chown=hive /opt/tez-snapshot /opt/tez-snapshot
101+
102+ # When TEZ_SNAPSHOT_VERSION is set, fetch Tez snapshot jars from the Maven snapshot repository
103+ # and place them under /opt/tez-snapshot. At runtime, entrypoint.sh symlinks these into
104+ # $HIVE_HOME/lib with a "0-" prefix so they sort first in bin/hive's classpath glob, ensuring
105+ # snapshot classes take precedence over the Tez release jars bundled with Hive.
106+ # Maven snapshot repositories use timestamped filenames (e.g. tez-api-1.0.0-20250101.jar),
107+ # so we fetch maven-metadata.xml first to resolve the exact filename before downloading the jar.
108+ RUN set -eux; \
109+ mkdir -p /opt/tez-snapshot-download; \
110+ if [[ -n "${TEZ_SNAPSHOT_VERSION}" ]]; then \
111+ base_url="${TEZ_SNAPSHOT_REPO_URL}/org/apache/tez" ; \
112+ for artifact in tez-common tez-api tez-dag tez-mapreduce tez-runtime-internals tez-runtime-library; do \
113+ version_url="${base_url}/${artifact}/${TEZ_SNAPSHOT_VERSION}" ; \
114+ metadata_url="${version_url}/maven-metadata.xml" ; \
115+ metadata_file="/opt/tez-snapshot-download/${artifact}-maven-metadata.xml" ; \
116+ echo "metadata_url=${metadata_url}" ; \
117+ wget -q "${metadata_url}" -O "${metadata_file}" ; \
118+ snapshot_value="$(xmlstarlet sel -t -v " string(/metadata/versioning/snapshotVersions/snapshotVersion[extension='jar' and not(classifier)]/value)" " ${metadata_file}")" ; \
119+ test -n "${snapshot_value}" ; \
120+ jar_file="${artifact}-${snapshot_value}.jar" ; \
121+ jar_url="${version_url}/${jar_file}" ; \
122+ echo "jar_url=${jar_url}" ; \
123+ wget -q "${jar_url}" -O "/opt/tez-snapshot/${jar_file}" ; \
124+ done; \
125+ echo "Downloaded Tez snapshot jars under /opt/tez-snapshot:" ; \
126+ ls -1 /opt/tez-snapshot/*.jar; \
127+ else \
128+ echo "TEZ_SNAPSHOT_VERSION not set. Skipping Tez snapshot download." ; \
129+ fi; \
130+ rm -rf /opt/tez-snapshot-download
131+
96132
97133COPY --chown=hive entrypoint.sh /
98134COPY --chown=hive conf $HIVE_HOME/conf
@@ -103,7 +139,8 @@ RUN chmod +x /entrypoint.sh && \
103139 mkdir -p $HIVE_HOME/scratch && \
104140 chown hive $HIVE_HOME/scratch && \
105141 mkdir -p /home/hive/.beeline && \
106- chown hive /home/hive/.beeline
142+ chown hive /home/hive/.beeline && \
143+ chown -R hive /opt/tez-snapshot
107144
108145USER hive
109146WORKDIR $HIVE_HOME
0 commit comments