You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "2010YOUY01 (via GitHub)" <gi...@apache.org> on 2025/12/10 09:56:24 UTC

[PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

2010YOUY01 opened a new pull request, #19254:
URL: https://github.com/apache/datafusion/pull/19254

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   A small step towards https://github.com/apache/datafusion/issues/19227
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   - Move doc prettier check command to a local script
   - Add this script to the lint-check runner `dev/rust_lint.sh` to make local development easier
     (Technically it's neither rust nor lint, but keeping all non functional tests here seem to be the most convenient.)
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on code in PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#discussion_r2703225368


##########
ci/scripts/doc_prettier_check.sh:
##########
@@ -0,0 +1,57 @@
+#!/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]}")"
+
+MODE="--check"

Review Comment:
   We have auto fixes for other lint violations now
   ```
   ./dev/rust_lint.sh --write --allow-dirty
   ```
   - In https://github.com/apache/datafusion/pull/19560
   
   I haven't used it extensively yet, so there may still be some bugs and potential improvements.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on code in PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#discussion_r2605963279


##########
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.                                                                                                                                                        |

Review Comment:
   injecting this `prettier` violation to ensure CI works as before.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on code in PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#discussion_r2609827780


##########
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

Review Comment:
   Good point! Updated in [573fd64](https://github.com/apache/datafusion/pull/19254/commits/573fd6427179ad984a976f0a25139764a5abfdbb)
   
   Now for check failures, the error message look like
   ```
   yongting@Yongtings-MacBook-Pro-2 ~/C/datafusion (doc-prettier-script *=) [1]> ./ci/scripts/doc_prettier_check.sh
   /Users/yongting/Code/datafusion/ci/scripts/doc_prettier_check.sh: Checking documents with prettier
   Checking formatting...
   [warn] docs/source/user-guide/metrics.md
   [warn] Code style issues found in the above file. Forgot to run Prettier?
   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.
   ```
   And we can use `--write` option to fix.
   
   I think there are several other potential auto fixes we can do, they can all be wrapped inside the lint script with `--write` option like
   ```
   # best-effort auto fixes for all available places
   ./dev/rust_lint.sh --write
   ```
   This idea is tracked in https://github.com/apache/datafusion/issues/19227



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#issuecomment-3641879804

   nice -- thank you @2010YOUY01 !


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#issuecomment-3644076223

   I ran it one more time manually
   
   ```shell
   (venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ ci/scripts/doc_prettier_check.sh
   /Users/andrewlamb/Software/datafusion/ci/scripts/doc_prettier_check.sh: Checking documents with prettier
   Checking formatting...
   [warn] docs/source/library-user-guide/upgrading.md
   [warn] Code style issues found in the above file. Forgot to run Prettier?
   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.
   (venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ ci/scripts/doc_prettier_check.sh --write
   /Users/andrewlamb/Software/datafusion/ci/scripts/doc_prettier_check.sh: Formatting documents with prettier
   ...
   (venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ ci/scripts/doc_prettier_check.sh
   /Users/andrewlamb/Software/datafusion/ci/scripts/doc_prettier_check.sh: Checking documents with prettier
   Checking formatting...
   All matched files use Prettier code style!
   (venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$
   ```


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #19254:
URL: https://github.com/apache/datafusion/pull/19254


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on code in PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#discussion_r2605963279


##########
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.                                                                                                                                                        |

Review Comment:
   Injecting this `prettier` violation to test CI works as before.
   
   It failed in https://github.com/apache/datafusion/actions/runs/20094525462/job/57649510711?pr=19254



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#discussion_r2703045436


##########
ci/scripts/doc_prettier_check.sh:
##########
@@ -0,0 +1,57 @@
+#!/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]}")"
+
+MODE="--check"

Review Comment:
   I use 
   ```shell
   ./ci/scripts/doc_prettier_check.sh --write
   ```
   
   All the time now in my dev workflow 👍 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#discussion_r2606307560


##########
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

Review Comment:
   I tested this out locally and it worked great for me:
   
   ```
   $ ./ci/scripts/doc_prettier_check.sh
   /Users/andrewlamb/Software/datafusion/ci/scripts/doc_prettier_check.sh: Checking document format with prettier
   Checking formatting...
   [warn] docs/source/library-user-guide/upgrading.md
   [warn] Code style issues found in the above file. Forgot to run Prettier?
   ./ci/scripts/doc_prettier_check.sh: line 41: prettier: command not found
   Prettier check failed. To fix, rerun  with --write (change --check to --write in the script), commit the formatted files, and re-run the check.
   ```
   
   I think it would be even nicer / better if it could also make the changes as well (so people don't have to do a second step to update the prettier docs)
   
   For example, if the check fails, maybe it could automatically re-run prettier with `--write`
   
   
   Or maybe the script could accept a `--write` command to get it to write?
   
   
   ```shell
   $ ./ci/scripts/doc_prettier_check.sh --write
   ```



##########
.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

Review Comment:
   👍 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] dev: Add CI doc prettier check to local `rust_lint.sh` [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#issuecomment-3644076635

   Love it -- thank you @2010YOUY01 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org