rdblue commented on code in PR #3709: URL: https://github.com/apache/parquet-java/pull/3709#discussion_r3884280387
########## dev/update-parquet-thrift.sh: ########## @@ -0,0 +1,161 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# Updates the inlined parquet.thrift and sidecar to a specific parquet-format +# commit or release. +# +# Usage: +# update-parquet-thrift.sh <full-40-char-commit-hash> -- POC: sets version=UNRELEASED +# update-parquet-thrift.sh --version <X.Y.Z> -- release sync: derives commit from tag + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" +THRIFT_FILE="${REPO_ROOT}/parquet-format-structures/src/main/thrift/parquet.thrift" +SIDECAR_FILE="${REPO_ROOT}/parquet-format-structures/src/main/thrift/parquet-format.version" + +# shellcheck source=parquet-thrift-lib.sh +source "${SCRIPT_DIR}/parquet-thrift-lib.sh" + +usage() { + cat <<EOF +Usage: + $0 <full-40-char-commit-hash> POC sync — fetch parquet.thrift at that commit; version=UNRELEASED + $0 --version <X.Y.Z> Release sync — resolve tag apache-parquet-format-<X.Y.Z> + +Only one of a commit hash or --version may be given, not both. +Commit mode requires a full 40-character sha (short shas cannot be fetched from a remote). +EOF + exit 1 +} + +if [[ $# -eq 0 ]]; then + usage +fi + +mode="" +commit_arg="" +version_arg="" + +if [[ "$1" == "--version" ]]; then + [[ $# -ne 2 ]] && usage + mode="version" + version_arg="$2" +elif [[ "$1" == --* ]]; then + usage +else + [[ $# -ne 1 ]] && usage + mode="commit" + commit_arg="$1" +fi + +# Validate arguments +if [[ "$mode" == "version" ]]; then + if ! [[ "$version_arg" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "ERROR: version must be X.Y.Z (e.g. 2.13.0), got: $version_arg" >&2 + exit 1 + fi +else + # Full 40-char sha required — short shas cannot be fetched from a remote (git exits 128). + if ! [[ "$commit_arg" =~ ^[0-9a-f]{40}$ ]]; then + echo "ERROR: commit hash must be exactly 40 hex chars, got: $commit_arg" >&2 + echo " Obtain the full sha with: git ls-remote ${PARQUET_FORMAT_REPO} HEAD" >&2 + exit 1 + fi +fi + +# Resolve the commit sha to use +resolved_sha="" +resolved_version="" + +if [[ "$mode" == "version" ]]; then + echo "Resolving tag apache-parquet-format-${version_arg} ..." + resolved_sha="$(resolve_version_to_commit "$version_arg")" || { + rc=$? + if [[ $rc -eq 1 ]]; then + echo "ERROR: tag apache-parquet-format-${version_arg} not found in ${PARQUET_FORMAT_REPO}" >&2 + echo " Check that the version exists: git ls-remote --tags ${PARQUET_FORMAT_REPO}" >&2 + else + echo "ERROR: git/network failure resolving tag apache-parquet-format-${version_arg}" >&2 + fi + exit 1 + } + resolved_version="$version_arg" + echo " -> commit: $resolved_sha" +else + resolved_sha="$commit_arg" + resolved_version="UNRELEASED" Review Comment: This isn't necessarily true. I think we should omit the resolved version instead of saying the content is not released. This could be a commit hash referring to a commit that is in a released version. -- 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]
