-
Notifications
You must be signed in to change notification settings - Fork 1.6k
GH-3708: Inline parquet.thrift #3709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8fa2a16
Inline parquet.thrift
divjotarora 600f8a5
Drop release-validation guard; simplify update script to single ref
divjotarora aaaf97b
Address PR review round 5: split awk END block to stay within 100-cha…
divjotarora 052098a
allow script to download from forks
divjotarora d5cd3ea
simplify script, add docs
divjotarora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| #!/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 tag. | ||
| # | ||
| # Usage: | ||
| # update-parquet-thrift.sh <ref> | ||
| # | ||
| # <ref> is a full 40-char parquet-format commit SHA, or a parquet-format tag | ||
| # (e.g. apache-parquet-format-2.13.0). | ||
| # | ||
| # Set PARQUET_FORMAT_REPO to pull from a fork instead of apache/parquet-format, | ||
| # e.g. PARQUET_FORMAT_REPO=https://github.com/<user>/parquet-format. | ||
|
|
||
| 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" | ||
|
|
||
| # Source repo, overridable via the PARQUET_FORMAT_REPO env var to pull from a fork. | ||
| # The raw-download host is derived from it (assumes a GitHub-hosted repo). | ||
| PARQUET_FORMAT_REPO="${PARQUET_FORMAT_REPO:-https://github.com/apache/parquet-format}" | ||
| PARQUET_FORMAT_RAW="${PARQUET_FORMAT_REPO/github.com/raw.githubusercontent.com}" | ||
| THRIFT_PATH_IN_FORMAT="src/main/thrift/parquet.thrift" | ||
|
|
||
| usage() { | ||
| cat <<EOF | ||
| Usage: $0 <ref> | ||
| <ref> a full 40-char parquet-format commit SHA, or a parquet-format tag | ||
| (e.g. apache-parquet-format-2.13.0) | ||
| EOF | ||
| exit 1 | ||
| } | ||
|
|
||
| [[ $# -ne 1 ]] && usage | ||
|
|
||
| ref="$1" | ||
|
|
||
| # Resolve ref to a full commit SHA. | ||
| if [[ "$ref" =~ ^[0-9a-f]{40}$ ]]; then | ||
| resolved_sha="$ref" | ||
| else | ||
| echo "Resolving ${ref} ..." | ||
| # ^{} refers to the unwrapped commit of an annotated tag, if present | ||
| ls_out="$(git ls-remote "$PARQUET_FORMAT_REPO" "$ref" "${ref}^{}")" || { | ||
|
divjotarora marked this conversation as resolved.
|
||
| echo "ERROR: git ls-remote failed for '${ref}' in ${PARQUET_FORMAT_REPO}" >&2 | ||
| exit 1 | ||
| } | ||
| if [[ -z "$ls_out" ]]; then | ||
| echo "ERROR: ref '${ref}' not found in ${PARQUET_FORMAT_REPO}" >&2 | ||
| exit 1 | ||
| fi | ||
| # The ^{} peeled commit (annotated tags) is listed last, so tail -1 selects it. | ||
| resolved_sha="$(printf '%s\n' "$ls_out" | tail -1 | cut -f1)" | ||
| if [[ -z "$resolved_sha" ]]; then | ||
| echo "ERROR: could not resolve commit SHA for '${ref}'" >&2 | ||
| exit 1 | ||
| fi | ||
| echo " -> commit: ${resolved_sha}" | ||
| fi | ||
|
|
||
| # Read the old commit from the sidecar for the summary. | ||
| old_commit="(none)" | ||
| if [[ -f "$SIDECAR_FILE" ]]; then | ||
| old_commit="$(grep '^parquet-format.commit=' "$SIDECAR_FILE" | cut -d= -f2 || true)" | ||
| fi | ||
|
|
||
| # Fetch upstream parquet.thrift to a temp file. Only overwrite the inlined file after fetch and | ||
| # validation succeed, so a failure never overwrites the tracked IDL. | ||
| tmp="$(mktemp)" | ||
| trap 'rm -f "$tmp"' EXIT | ||
|
|
||
| echo "Fetching parquet.thrift at ${resolved_sha} ..." | ||
| url="${PARQUET_FORMAT_RAW}/${resolved_sha}/${THRIFT_PATH_IN_FORMAT}" | ||
| if ! curl -fsSL -o "$tmp" "$url"; then | ||
| echo "ERROR: could not fetch parquet.thrift at ${resolved_sha}" >&2 | ||
| echo " The tracked files were not modified." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! -s "$tmp" ]]; then | ||
| echo "ERROR: fetched parquet.thrift is empty" >&2 | ||
| exit 1 | ||
| fi | ||
| if ! grep -q 'namespace java org.apache.parquet.format' "$tmp"; then | ||
| echo "ERROR: fetched file does not look like parquet.thrift (missing namespace declaration)" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Write the validated thrift file, then write the sidecar. | ||
| mv "$tmp" "$THRIFT_FILE" | ||
| chmod 644 "$THRIFT_FILE" | ||
| echo " -> written to ${THRIFT_FILE}" | ||
|
|
||
| cat > "$SIDECAR_FILE" <<SIDECAR | ||
| # Provenance of the inlined parquet.thrift. Maintained by dev/update-parquet-thrift.sh. | ||
| parquet-format.commit=${resolved_sha} | ||
| SIDECAR | ||
| echo " -> sidecar updated: ${SIDECAR_FILE}" | ||
|
|
||
| # Summary | ||
| echo "" | ||
| echo "Update complete:" | ||
| echo " old commit: ${old_commit}" | ||
| echo " new commit: ${resolved_sha}" | ||
| echo "" | ||
| echo "Next steps: rebuild parquet-format-structures and review the diff:" | ||
| echo " ./mvnw -pl parquet-format-structures -am install -DskipTests" | ||
| echo " git diff parquet-format-structures/src/main/thrift/parquet.thrift" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
parquet-format-structures/src/main/thrift/parquet-format.version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Provenance of the inlined parquet.thrift. Maintained by dev/update-parquet-thrift.sh. | ||
| parquet-format.commit=c47e2a66e88943fc46fde1b028a9432f14fdf5c0 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a name that refers to the thrift file, rather than to the parquet-format repo, but this is minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should leave this as-is to indicate that the provenance of the
parquet.thriftfile is the parquet-format repo. Can change if you feel strongly though