From 32762e3a91b8ffcd42746bf08ec3eabca7bf6a70 Mon Sep 17 00:00:00 2001 From: Yongting You <2010youy01@gmail.com> Date: Wed, 10 Dec 2025 17:48:49 +0800 Subject: [PATCH 1/3] add doc prettier check to `rust_lint.sh` --- .github/workflows/dev.yml | 14 +++------- ci/scripts/doc_prettier_check.sh | 43 +++++++++++++++++++++++++++++++ dev/rust_lint.sh | 1 + docs/source/user-guide/metrics.md | 2 +- 4 files changed, 48 insertions(+), 12 deletions(-) create mode 100755 ci/scripts/doc_prettier_check.sh diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 1bd51fb8957a8..1ec7c16b488f5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -48,16 +48,8 @@ jobs: with: node-version: "20" - name: Prettier check - run: | - # if you encounter error, rerun the command below and commit the changes - # - # ignore subproject CHANGELOG.md because they are machine generated - npx prettier@2.7.1 --write \ - '{datafusion,datafusion-cli,datafusion-examples,dev,docs}/**/*.md' \ - '!datafusion/CHANGELOG.md' \ - README.md \ - CONTRIBUTING.md - git diff --exit-code + # if you encounter error, see instructions inside the script + run: ci/scripts/doc_prettier_check.sh typos: name: Spell Check with Typos @@ -72,4 +64,4 @@ jobs: - name: Install typos-cli run: cargo install typos-cli --locked --version 1.37.0 - name: Run typos check - run: ci/scripts/typos_check.sh \ No newline at end of file + run: ci/scripts/typos_check.sh diff --git a/ci/scripts/doc_prettier_check.sh b/ci/scripts/doc_prettier_check.sh new file mode 100755 index 0000000000000..3246544688c6b --- /dev/null +++ b/ci/scripts/doc_prettier_check.sh @@ -0,0 +1,43 @@ +#!/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. + +SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" +echo "$SCRIPT_PATH: Checking document format with prettier" + +# Ensure `npx` is available +if ! command -v npx >/dev/null 2>&1; then + echo "npx is required to run the prettier check. Install Node.js (e.g., brew install node) and re-run." >&2 + exit 1 +fi + +# if you encounter error, change '--check' to '--write' in the below command, and +# commit the change. +# +# Ignore subproject CHANGELOG.md because it is machine generated +npx prettier@2.7.1 --check \ + '{datafusion,datafusion-cli,datafusion-examples,dev,docs}/**/*.md' \ + '!datafusion/CHANGELOG.md' \ + README.md \ + CONTRIBUTING.md +status=$? + +if [ $status -ne 0 ]; then + echo "Prettier check failed. To fix, rerun `prettier` with --write (change --check to --write in the script), commit the formatted files, and re-run the check." >&2 + exit $status +fi diff --git a/dev/rust_lint.sh b/dev/rust_lint.sh index 490720c537cfb..21d4611846413 100755 --- a/dev/rust_lint.sh +++ b/dev/rust_lint.sh @@ -49,3 +49,4 @@ ci/scripts/rust_toml_fmt.sh ci/scripts/rust_docs.sh ci/scripts/license_header.sh ci/scripts/typos_check.sh +ci/scripts/doc_prettier_check.sh diff --git a/docs/source/user-guide/metrics.md b/docs/source/user-guide/metrics.md index 7e0363f4ceb9b..0e1e7dc642b75 100644 --- a/docs/source/user-guide/metrics.md +++ b/docs/source/user-guide/metrics.md @@ -30,7 +30,7 @@ DataFusion operators expose runtime metrics so you can understand where time is | Metric | Description | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | elapsed_compute | CPU time the operator actively spends processing work. | -| output_rows | Total number of rows the operator produces. | +| output_rows | Total number of rows the operator produces. | | output_bytes | Memory usage of all output batches. Note: This value may be overestimated. If multiple output `RecordBatch` instances share underlying memory buffers, their sizes will be counted multiple times. | | output_batches | Total number of output batches the operator produces. | From f8296dd886fb4db6cec053516858180b4c9e712b Mon Sep 17 00:00:00 2001 From: Yongting You <2010youy01@gmail.com> Date: Wed, 10 Dec 2025 17:58:32 +0800 Subject: [PATCH 2/3] revert prettier check violation --- docs/source/user-guide/metrics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-guide/metrics.md b/docs/source/user-guide/metrics.md index 0e1e7dc642b75..7e0363f4ceb9b 100644 --- a/docs/source/user-guide/metrics.md +++ b/docs/source/user-guide/metrics.md @@ -30,7 +30,7 @@ DataFusion operators expose runtime metrics so you can understand where time is | Metric | Description | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | elapsed_compute | CPU time the operator actively spends processing work. | -| output_rows | Total number of rows the operator produces. | +| output_rows | Total number of rows the operator produces. | | output_bytes | Memory usage of all output batches. Note: This value may be overestimated. If multiple output `RecordBatch` instances share underlying memory buffers, their sizes will be counted multiple times. | | output_batches | Total number of output batches the operator produces. | From 573fd6427179ad984a976f0a25139764a5abfdbb Mon Sep 17 00:00:00 2001 From: Yongting You <2010youy01@gmail.com> Date: Thu, 11 Dec 2025 17:21:48 +0800 Subject: [PATCH 3/3] review: update the script with --write option --- ci/scripts/doc_prettier_check.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/ci/scripts/doc_prettier_check.sh b/ci/scripts/doc_prettier_check.sh index 3246544688c6b..d94a0d1c96171 100755 --- a/ci/scripts/doc_prettier_check.sh +++ b/ci/scripts/doc_prettier_check.sh @@ -18,7 +18,20 @@ # under the License. SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" -echo "$SCRIPT_PATH: Checking document format with prettier" + +MODE="--check" +ACTION="Checking" +if [ $# -gt 0 ]; then + if [ "$1" = "--write" ]; then + MODE="--write" + ACTION="Formatting" + else + echo "Usage: $0 [--write]" >&2 + exit 1 + fi +fi + +echo "$SCRIPT_PATH: $ACTION documents with prettier" # Ensure `npx` is available if ! command -v npx >/dev/null 2>&1; then @@ -26,11 +39,8 @@ if ! command -v npx >/dev/null 2>&1; then exit 1 fi -# if you encounter error, change '--check' to '--write' in the below command, and -# commit the change. -# # Ignore subproject CHANGELOG.md because it is machine generated -npx prettier@2.7.1 --check \ +npx prettier@2.7.1 $MODE \ '{datafusion,datafusion-cli,datafusion-examples,dev,docs}/**/*.md' \ '!datafusion/CHANGELOG.md' \ README.md \ @@ -38,6 +48,10 @@ npx prettier@2.7.1 --check \ status=$? if [ $status -ne 0 ]; then - echo "Prettier check failed. To fix, rerun `prettier` with --write (change --check to --write in the script), commit the formatted files, and re-run the check." >&2 + if [ "$MODE" = "--check" ]; then + echo "Prettier check failed. Re-run with --write (e.g., ./ci/scripts/doc_prettier_check.sh --write) to format files, commit the changes, and re-run the check." >&2 + else + echo "Prettier format failed. Files may have been modified; commit any changes and re-run." >&2 + fi exit $status fi