Repository navigation
feat: add datafusion-spark-cli, a SQL shell with the Spark functions #326
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
Open
andygrove
wants to merge
4
commits into
apache:main
Choose a base branch
from
andygrove:feat-spark-cli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2d22fc5
feat: add datafusion-spark-cli, a SQL shell with the Spark functions
andygrove 02c9cc6
Merge remote-tracking branch 'apache/main' into feat-spark-cli
andygrove f0cf6de
fix(cli): resolve -f and -r paths before changing to the data path
andygrove a167618
Merge remote-tracking branch 'apache/main' into HEAD
andygrove 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership | ||
| # SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements | ||
|
|
||
| name: CLI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| smoke-test: | ||
| name: datafusion-spark-cli smoke test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - run: rustup toolchain install stable --profile minimal --no-self-update && rustup default stable | ||
| - uses: Swatinem/rust-cache@v2 | ||
| - run: cargo build -p datafusion-spark-cli | ||
| # A Spark function, and ANSI mode on by default and off with `--ansi false`. | ||
| - name: Run queries | ||
| run: | | ||
| set -euo pipefail | ||
| cli=target/debug/datafusion-spark-cli | ||
| $cli -q --format csv -c "SELECT sha2('Spark', 256) AS h" \ | ||
| | grep -x '529bc3b07127ecb7e53a4dcf1991d9152c24537d919178022b2c42657f79a26b' | ||
| if out=$($cli -q -c "SELECT abs(cast(-2147483648 AS int))" 2>&1); then | ||
| echo "expected an ARITHMETIC_OVERFLOW error with ANSI mode on" && exit 1 | ||
| fi | ||
| grep -F '[ARITHMETIC_OVERFLOW]' <<< "$out" | ||
| $cli -q --ansi false --format csv -c "SELECT abs(cast(-2147483648 AS int)) AS a" \ | ||
| | grep -x -- '-2147483648' | ||
| # SQL read from stdin by the REPL. `LONG` is a type in the Spark dialect only. | ||
| - name: Run the REPL from stdin | ||
| run: | | ||
| set -euo pipefail | ||
| echo "SELECT CAST(1 AS LONG) AS l;" \ | ||
| | target/debug/datafusion-spark-cli -q --format csv | grep -x '1' | ||
| # `-f` and `-r` paths are relative to the working directory, not to `-p`. | ||
| - name: Run files with a data path | ||
| run: | | ||
| set -euo pipefail | ||
| cli=$PWD/target/debug/datafusion-spark-cli | ||
| dir=$(mktemp -d) && cd "$dir" && mkdir data | ||
| echo "SELECT 'cwd' AS s;" > q.sql | ||
| echo "SELECT 'data' AS s;" > data/q.sql | ||
| $cli -q --format csv -p data -f q.sql | grep -x 'cwd' | ||
| echo "" | $cli -q --format csv -p data -r q.sql | grep -x 'cwd' | ||
| echo "SELECT 'stdin' AS s;" | $cli -q --format csv -p data -f /dev/stdin | grep -x 'stdin' | ||
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
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.
Could we add a stdin REPL smoke test using
CAST(1 AS LONG)and assert the result row? Current queries also pass with the generic dialect, so they do not verify Spark parsing.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.
Added in f0cf6de. CI pipes
SELECT CAST(1 AS LONG) AS l;into the REPL and checks for the row1.