Skip to content

beam-sql.sh, a standalone launcher for Beam SQL Shell - #36305

Merged
chamikaramj merged 7 commits into
apache:masterfrom
talatuyarer:beam-shell
Oct 14, 2025
Merged

beam-sql.sh, a standalone launcher for Beam SQL Shell#36305
chamikaramj merged 7 commits into
apache:masterfrom
talatuyarer:beam-shell

Conversation

@talatuyarer

Copy link
Copy Markdown
Contributor

Currently, using the Beam SQL shell requires cloning the entire Beam repository and running a complex Gradle command with specific project properties just to bundle I/O connectors (e.g., ./gradlew ... -Pbeam.sql.shell.bundled=... installDist). This process is slow on the first run, non-intuitive, and makes it difficult to quickly experiment with different connectors.

This PR introduces beam-sql.sh, a new standalone Bash script that completely automates this process. It provides a simple, powerful, and user-friendly command-line experience for launching the SQL Shell with any required I/O connectors and runners.

Key Features

The ``beam-sql.sh` script is a self-contained utility with the following features:

  • Dynamic Dependencies: Users can specify the Beam version, I/O connectors (--io), and runners (--runner) directly via command-line flags.

  • Robust JAR Building: The script dynamically generates a pom.xml and builds a self-contained "uber JAR" using the maven-shade-plugin. It correctly uses the ServicesResourceTransformer to merge META-INF/services files, ensuring all specified connectors are discoverable by the Java ServiceLoader.

  • Intelligent Caching: Successfully built JARs are cached locally in ~/.beamshell/cache. Subsequent launches with the same configuration are instantaneous, as the script finds and uses the cached JAR, skipping the build step entirely.

  • No Maven Required: The script makes no assumption about a user's environment. It will use the system-installed mvn if present for speed, but will automatically download and use the Maven Wrapper (mvnw) if mvn is not found, making it highly portable.

  • Standalone & Easy to Use: It is a single Bash script with minimal, common dependencies (java, curl), making it easy to distribute and use.

How to Use

The script provides a simple and flexible command-line interface.

1. Basic launch with Iceberg support:

./beam-sql.sh --io iceberg
./beamshell --version 2.56.0 --io kafka --io jdbc

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @talatuyarer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces beam-sql.sh, a new standalone Bash script designed to significantly streamline the process of launching the Apache Beam SQL Shell. It eliminates the need for manual repository cloning and complex Gradle commands by automating dependency management, building a self-contained executable JAR with specified I/O connectors and runners, and intelligently caching these builds for rapid subsequent use. The script aims to provide a user-friendly and portable command-line experience for Beam SQL users.

Highlights

  • Standalone Launcher Script: Introduces beam-sql.sh, a new standalone Bash script that automates the process of launching the Beam SQL Shell, simplifying dependency management and execution.
  • Dynamic Dependency Management: Users can specify the Beam version, I/O connectors (--io), and runners (--runner) directly via command-line flags, allowing for flexible configuration without manual setup.
  • Robust JAR Building with Maven Shade Plugin: The script dynamically generates a pom.xml and builds a self-contained 'uber JAR' using the maven-shade-plugin, ensuring proper service loading for all specified connectors.
  • Intelligent Caching: Successfully built JARs are cached locally in ~/.beamshell/cache. Subsequent launches with the same configuration are instantaneous, as the script reuses the cached JAR.
  • No Maven Required: The script is highly portable; it will use a system-installed mvn if available, but automatically downloads and uses the Maven Wrapper (mvnw) if mvn is not found.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@talatuyarer

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a very useful beam-sql.sh script that significantly simplifies launching the Beam SQL shell. The script is well-designed, with features like dynamic dependency management, caching, and automatic Maven wrapper setup. The accompanying documentation updates are also clear and helpful.

My review focuses on a few areas to improve the long-term maintainability of the script and the documentation. Specifically, I've suggested centralizing hardcoded versions in the script and refactoring the dynamic POM generation for better readability. For the documentation, I've pointed out a few places where hardcoded version numbers could be replaced with more generic text to prevent the docs from becoming stale.

Overall, this is an excellent addition that will greatly improve the user experience for Beam SQL.

Comment thread scripts/beam-sql.sh Outdated
Comment on lines +41 to +46
# Define URLs for a stable version of the wrapper files
local mvnw_script_url="https://raw.githubusercontent.com/apache/maven-wrapper/maven-wrapper-3.2.0/src/main/wrapper/mvnw"
local wrapper_jar_url="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"

# We will create the properties file ourselves to specify a modern Maven version
echo "distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip" > "${wrapper_dir}/maven-wrapper.properties"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block hardcodes URLs and versions for the Maven wrapper and Maven itself. For better maintainability, it's recommended to define these as constants at the top of the script in the Configuration section (lines 24-29). This would also apply to the maven-shade-plugin version on line 206. Centralizing these values makes them easier to find and update.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with gemini :-)

Comment thread scripts/beam-sql.sh
Comment thread website/www/site/content/en/documentation/dsls/sql/shell.md Outdated
Comment thread website/www/site/content/en/documentation/dsls/sql/shell.md Outdated
Comment thread website/www/site/content/en/documentation/dsls/sql/shell.md
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label website.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@kennknowles kennknowles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. I added comments for the future. I think removing the "build from source" docs right away is a good idea. We can move them to the README.md in the github repo or something, if they are needed for devs. They were never a good instruction for users.

./beam-sql.sh --list-versions
```

### Option 2: Building from Source

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this option. Only Beam devs need to know how to build it from souce.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread website/www/site/content/en/documentation/dsls/sql/shell.md Outdated
Comment thread scripts/beam-sql.sh
Comment thread scripts/beam-sql.sh Outdated
DEFAULT_BEAM_VERSION="2.67.0"
MAIN_CLASS="org.apache.beam.sdk.extensions.sql.jdbc.BeamSqlLine"
# Directory to store cached executable JAR files
CACHE_DIR="${HOME}/.beamshell/cache"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just make this .beam so that it can be for anything Beam ends up doing? Or it could be .beam-sql so that it is clearly for this SQL application. I prefer .beam

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Make sense

Comment thread scripts/beam-sql.sh
Comment thread scripts/beam-sql.sh Outdated
echo ""
echo "Options:"
echo " --version Specify the Apache Beam version (default: ${DEFAULT_BEAM_VERSION})."
echo " --runner Specify the Beam runner to use (default: direct). Supported: direct, dataflow."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can already tell that this shell script will eventually graduate to something written in a language that can have a real argument parser :-)

Comment thread scripts/beam-sql.sh
Comment thread scripts/beam-sql.sh
Comment thread scripts/beam-sql.sh Outdated
Comment thread scripts/beam-sql.sh
@github-actions github-actions Bot added build and removed build labels Sep 30, 2025
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions github-actions Bot added the build label Sep 30, 2025
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

@chamikaramj chamikaramj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread scripts/beam-sql.sh
Comment thread scripts/beam-sql.sh Outdated
Comment thread scripts/beam-sql.sh
Comment thread scripts/beam-sql.sh
Comment thread website/www/site/content/en/documentation/dsls/sql/shell.md Outdated

```bash
# Use a specific Beam version
./beam-sql.sh --version 2.66.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also set this to the latest version during release time. We already do this for documentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know how can I do that. Can you help me ? @chamikaramj

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Python you can try this:

from apache_beam.version import __version__ as beam_version

For documentation we use this:

release_latest = "2.68.0"

Both updated during Beam releases.

Comment thread website/www/site/content/en/documentation/dsls/sql/shell.md
Comment thread website/www/site/content/en/documentation/dsls/sql/shell.md Outdated
Comment thread website/www/site/content/en/documentation/dsls/sql/shell.md
Comment thread website/www/site/content/en/documentation/dsls/sql/shell.md
@chamikaramj

Copy link
Copy Markdown
Contributor

Thanks. LGTM.

@ahmedabu98 ahmedabu98 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall, just left some comments.

Also, does this support passing in pipeline options (I'm thinking to set up the Dataflow runner)

Comment thread scripts/beam-sql.sh
Comment thread scripts/beam-sql.sh
echo " Supported runners:"
echo " direct - DirectRunner (runs locally, good for development)"
echo " dataflow - DataflowRunner (runs on Google Cloud Dataflow)"
echo " --io Specify an IO connector to include. Can be used multiple times."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider making this a comma-separated list for easy use

Comment thread scripts/beam-sql.sh
Comment on lines +262 to +264
"prism")
echo " prism - PrismRunner"
echo " Local runner for testing portable pipelines."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we trying to encourage PrismRunner usage? @damccorm @liferoad

If it's in a good state, maybe it should be listed up higher next to direct runner and dataflow

Comment thread scripts/beam-sql.sh
EOL
# Add IO and Runner dependencies
for io in "${IO_CONNECTORS[@]}"; do
echo " <dependency><groupId>org.apache.beam</groupId><artifactId>beam-sdks-java-io-${io}</artifactId><version>\${beam.version}</version></dependency>" >> "${POM_FILE}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for Iceberg, we'll also need to add beam-sdks-java-extensions-sql-iceberg

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These things are resolved by maven I am just created a project which uses necessary dependencies.

@talatuyarer

Copy link
Copy Markdown
Contributor Author

Looks great overall, just left some comments.

Also, does this support passing in pipeline options (I'm thinking to set up the Dataflow runner)

We dont need to pass pipelineoptions any Pipelineoptions has to be set by SQL SET syntax. Example from documentation:

Screenshot 2025-10-08 at 12 26 52 PM

@chamikaramj
chamikaramj merged commit ed39cbb into apache:master Oct 14, 2025
102 of 107 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants