Skip to content

[Enhance](system table) Push down predicates for table_stream_consumption metadata scan #59859

[Enhance](system table) Push down predicates for table_stream_consumption metadata scan

[Enhance](system table) Push down predicates for table_stream_consumption metadata scan #59859

name: Code Review
on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review, edited, closed]
issue_comment:
types: [created]
permissions:
contents: read
pull-requests: read
statuses: write
jobs:
accept-skill-review:
name: Accept local skill review PASS
runs-on: ubuntu-latest
outputs:
accepted: ${{ steps.validation.outputs.valid }}
head_sha: ${{ steps.validation.outputs.head_sha }}
if: >
github.event_name == 'issue_comment' &&
github.event.issue.pull_request != null &&
contains(github.event.comment.body, '<!-- doris-repo-review:v1:begin -->')
steps:
# A local PASS is a creation-time credential. Later edits, deletion, or
# permission changes do not revoke it; edited events are intentionally ignored.
- name: Authorize review comment creator
id: authorization
env:
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
EVENT_SENDER: ${{ github.event.sender.login }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
if [ "$COMMENT_AUTHOR" != "$EVENT_SENDER" ]; then
echo "Review comment ignored: creator and event sender differ."
echo "authorized=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! permission_info="$(gh api "repos/${REPO}/collaborators/${COMMENT_AUTHOR}/permission")"; then
echo "Review comment ignored: cannot verify ${COMMENT_AUTHOR}'s repository permission."
echo "authorized=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! comment_author_permission="$(jq -er '.permission | strings' <<<"$permission_info")"; then
echo "Review comment ignored: cannot read ${COMMENT_AUTHOR}'s repository permission."
echo "authorized=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "$comment_author_permission" != "write" && "$comment_author_permission" != "admin" ]]; then
echo "Review comment ignored: ${COMMENT_AUTHOR} does not have write permission."
echo "authorized=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "authorized=true" >> "$GITHUB_OUTPUT"
echo "permission=$comment_author_permission" >> "$GITHUB_OUTPUT"
- name: Checkout trusted validation script
if: steps.authorization.outputs.authorized == 'true'
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
sparse-checkout: .github/scripts/validate_review_pass_comment.py
sparse-checkout-cone-mode: false
- name: Validate local review comment
if: steps.authorization.outputs.authorized == 'true'
id: validation
env:
COMMENT_AUTHOR_PERMISSION: ${{ steps.authorization.outputs.permission }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
run: |
comment_file="$RUNNER_TEMP/doris-repo-review-comment.md"
jq -r '.comment.body' "$GITHUB_EVENT_PATH" > "$comment_file"
pr_info="$(gh api "repos/${REPO}/pulls/${PR_NUMBER}")"
head_sha="$(jq -r '.head.sha' <<<"$pr_info")"
live_base_sha="$(jq -r '.base.sha' <<<"$pr_info")"
pr_state="$(jq -r '.state' <<<"$pr_info")"
if [ "$pr_state" != "open" ]; then
echo "Review comment ignored: pull request is ${pr_state}."
echo "valid=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! reviewed_base_sha="$(python3 .github/scripts/validate_review_pass_comment.py \
extract-base --comment-file "$comment_file")"; then
echo "Review comment ignored: cannot read its reviewed base."
echo "valid=false" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! base_compare="$(gh api \
"repos/${REPO}/compare/${reviewed_base_sha}...${live_base_sha}")"; then
echo "Review comment ignored: cannot compare its base with the current PR base."
echo "valid=false" >> "$GITHUB_OUTPUT"
exit 0
fi
base_compare_status="$(jq -r '.status' <<<"$base_compare")"
if [ "$reviewed_base_sha" = "$live_base_sha" ]; then
reviewed_base_committed_at=""
live_base_committed_at=""
else
if ! reviewed_base_committed_at="$(gh api \
"repos/${REPO}/commits/${reviewed_base_sha}" --jq '.commit.committer.date')" || \
! live_base_committed_at="$(gh api \
"repos/${REPO}/commits/${live_base_sha}" --jq '.commit.committer.date')"; then
echo "Review comment ignored: cannot resolve base commit times."
echo "valid=false" >> "$GITHUB_OUTPUT"
exit 0
fi
fi
if validation_output="$(python3 .github/scripts/validate_review_pass_comment.py validate \
--comment-file "$comment_file" \
--repository "$REPO" \
--pr-number "$PR_NUMBER" \
--head-sha "$head_sha" \
--live-base-sha "$live_base_sha" \
--base-compare-status "$base_compare_status" \
--reviewed-base-committed-at "$reviewed_base_committed_at" \
--live-base-committed-at "$live_base_committed_at" \
--comment-author "$COMMENT_AUTHOR" \
--comment-author-permission "$COMMENT_AUTHOR_PERMISSION" 2>&1)"; then
echo "$validation_output"
echo "valid=true" >> "$GITHUB_OUTPUT"
echo "head_sha=$head_sha" >> "$GITHUB_OUTPUT"
echo "base_sha=$live_base_sha" >> "$GITHUB_OUTPUT"
else
echo "$validation_output"
echo "valid=false" >> "$GITHUB_OUTPUT"
fi
- name: Record local review source
if: steps.validation.outputs.valid == 'true'
env:
BASE_SHA: ${{ steps.validation.outputs.base_sha }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
HEAD_SHA: ${{ steps.validation.outputs.head_sha }}
COMMENT_URL: ${{ github.event.comment.html_url }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
source_context="code-review/source/local/pr-${PR_NUMBER}/base-${BASE_SHA}"
gh api "repos/${REPO}/statuses/${HEAD_SHA}" \
-X POST \
-f state='pending' \
-f context='code-review' \
-f description="Recalculating code review for PR #${PR_NUMBER}." \
-f target_url="$COMMENT_URL"
gh api "repos/${REPO}/statuses/${HEAD_SHA}" \
-X POST \
-f state='success' \
-f context="$source_context" \
-f description="Local review passed for PR #${PR_NUMBER} at ${BASE_SHA:0:12}." \
-f target_url="$COMMENT_URL"
aggregate-after-skill-review:
needs: accept-skill-review
if: needs.accept-skill-review.outputs.accepted == 'true'
uses: ./.github/workflows/code-review-aggregate-status.yml
with:
head_sha: ${{ needs.accept-skill-review.outputs.head_sha }}
permissions:
contents: read
pull-requests: read
statuses: write
skip-on-comment:
name: Skip review via skip buildall comment
runs-on: ubuntu-latest
outputs:
accepted: ${{ steps.skip.outputs.accepted }}
head_sha: ${{ steps.skip.outputs.head_sha }}
if: >
github.event_name == 'issue_comment' &&
github.event.issue.pull_request != null &&
!startsWith(github.event.comment.body, '/review') &&
contains(github.event.comment.body, 'skip buildall')
steps:
- name: Check user permission and mark review as success
id: skip
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
COMMENT_USER_ID: ${{ github.event.comment.user.id }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
PR_INFO=$(gh api repos/${REPO}/pulls/${PR_NUMBER})
HEAD_SHA=$(echo "${PR_INFO}" | jq -r '.head.sha')
BASE_SHA=$(echo "${PR_INFO}" | jq -r '.base.sha')
TARGET_BRANCH=$(echo "${PR_INFO}" | jq -r '.base.ref')
ALLOWED=false
if [[ "${COMMENT_USER_ID}" == '27881198' || "${COMMENT_USER_ID}" == '37901441' || "${COMMENT_USER_ID}" == '61408379' ]]; then
ALLOWED=true
elif [[ "${COMMENT_USER_ID}" == '9208457' && "${TARGET_BRANCH}" == *'branch-2.1'* ]]; then
ALLOWED=true
elif [[ "${COMMENT_USER_ID}" == '98214048' && "${TARGET_BRANCH}" == *'branch-3.0'* ]]; then
ALLOWED=true
elif [[ "${COMMENT_USER_ID}" == '101034200' && "${TARGET_BRANCH}" == *'branch-3.1'* ]]; then
ALLOWED=true
elif [[ ("${COMMENT_USER_ID}" == '9208457' || "${COMMENT_USER_ID}" == '2899462') && "${TARGET_BRANCH}" == *'branch-4.0'* ]]; then
ALLOWED=true
elif [[ "${COMMENT_USER_ID}" == '9208457' && "${TARGET_BRANCH}" == *'branch-4.1'* ]]; then
ALLOWED=true
fi
if [[ "${ALLOWED}" != 'true' ]]; then
echo "COMMENT_USER_ID ${COMMENT_USER_ID} is not allowed to skip code review."
echo "accepted=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "COMMENT_USER_ID ${COMMENT_USER_ID} is allowed to skip code review for ${TARGET_BRANCH}."
source_context="code-review/source/skip/pr-${PR_NUMBER}/base-${BASE_SHA}"
gh api repos/${REPO}/statuses/${HEAD_SHA} \
-X POST \
-f state="pending" \
-f context='code-review' \
-f description="Recalculating code review for PR #${PR_NUMBER}." \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
gh api repos/${REPO}/statuses/${HEAD_SHA} \
-X POST \
-f state="success" \
-f context="$source_context" \
-f description="Code review skipped for PR #${PR_NUMBER} at ${BASE_SHA:0:12}." \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
echo "accepted=true" >> "$GITHUB_OUTPUT"
echo "head_sha=$HEAD_SHA" >> "$GITHUB_OUTPUT"
aggregate-after-skip:
needs: skip-on-comment
if: needs.skip-on-comment.outputs.accepted == 'true'
uses: ./.github/workflows/code-review-aggregate-status.yml
with:
head_sha: ${{ needs.skip-on-comment.outputs.head_sha }}
permissions:
contents: read
pull-requests: read
statuses: write
sync-status:
name: Sync review status
if: github.event_name == 'pull_request_target'
uses: ./.github/workflows/code-review-aggregate-status.yml
with:
head_sha: ${{ github.event.pull_request.head.sha }}
permissions:
contents: read
pull-requests: read
statuses: write
sync-previous-head-status:
name: Sync previous review status
if: >
github.event_name == 'pull_request_target' &&
github.event.action == 'synchronize' &&
github.event.before != '' &&
github.event.before != github.event.pull_request.head.sha
uses: ./.github/workflows/code-review-aggregate-status.yml
with:
head_sha: ${{ github.event.before }}
permissions:
contents: read
pull-requests: read
statuses: write