Skip to content

Commit 1624912

Browse files
committed
Merge remote-tracking branch 'origin/main' into addAppendpipe
2 parents 7664cd5 + 23dc638 commit 1624912

532 files changed

Lines changed: 15777 additions & 3712 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish unified query modules to maven
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- '[0-9]+.[0-9]+'
9+
- '[0-9]+.x'
10+
11+
env:
12+
SNAPSHOT_REPO_URL: https://ci.opensearch.org/ci/dbc/snapshots/maven/
13+
14+
jobs:
15+
publish-unified-query-modules:
16+
strategy:
17+
fail-fast: false
18+
if: github.repository == 'opensearch-project/sql'
19+
runs-on: ubuntu-latest
20+
21+
permissions:
22+
id-token: write
23+
contents: write
24+
25+
steps:
26+
- uses: actions/setup-java@v3
27+
with:
28+
distribution: temurin # Temurin is a distribution of adoptium
29+
java-version: 21
30+
- uses: actions/checkout@v3
31+
- name: Load secret
32+
uses: 1password/load-secrets-action@v2
33+
with:
34+
# Export loaded secrets as environment variables
35+
export-env: true
36+
env:
37+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
38+
MAVEN_SNAPSHOTS_S3_REPO: op://opensearch-infra-secrets/maven-snapshots-s3/repo
39+
MAVEN_SNAPSHOTS_S3_ROLE: op://opensearch-infra-secrets/maven-snapshots-s3/role
40+
- name: Configure AWS credentials
41+
uses: aws-actions/configure-aws-credentials@v5
42+
with:
43+
role-to-assume: ${{ env.MAVEN_SNAPSHOTS_S3_ROLE }}
44+
aws-region: us-east-1
45+
- name: publish snapshots to maven
46+
run: |
47+
./gradlew publishUnifiedQueryPublicationToSnapshotsRepository

.github/workflows/maven-publish.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ on:
88
- '[0-9]+.[0-9]+'
99
- '[0-9]+.x'
1010

11-
env:
12-
SNAPSHOT_REPO_URL: https://ci.opensearch.org/ci/dbc/snapshots/maven/
13-
1411
jobs:
1512
build-and-publish-snapshots:
1613
strategy:

.github/workflows/publish-async-query-core.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
push:
66
branches:
77
- main
8-
- 1.*
9-
- 2.*
8+
- '[0-9]+.[0-9]+'
9+
- '[0-9]+.x'
1010
paths:
1111
- 'async-query-core/**'
1212
- '.github/workflows/publish-async-query-core.yml'
@@ -18,7 +18,6 @@ concurrency:
1818
cancel-in-progress: false
1919

2020
env:
21-
SNAPSHOT_REPO_URL: https://central.sonatype.com/repository/maven-snapshots/
2221
COMMIT_MAP_FILENAME: commit-history-async-query-core.json
2322

2423
jobs:
@@ -47,8 +46,19 @@ jobs:
4746
export-env: true
4847
env:
4948
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
50-
SONATYPE_USERNAME: op://opensearch-infra-secrets/maven-central-portal-credentials/username
51-
SONATYPE_PASSWORD: op://opensearch-infra-secrets/maven-central-portal-credentials/password
49+
MAVEN_SNAPSHOTS_S3_REPO: op://opensearch-infra-secrets/maven-snapshots-s3/repo
50+
MAVEN_SNAPSHOTS_S3_ROLE: op://opensearch-infra-secrets/maven-snapshots-s3/role
51+
52+
- name: Export SNAPSHOT_REPO_URL
53+
run: |
54+
snapshot_repo_url=${{ env.MAVEN_SNAPSHOTS_S3_REPO }}
55+
echo "SNAPSHOT_REPO_URL=$snapshot_repo_url" >> $GITHUB_ENV
56+
57+
- name: Configure AWS credentials
58+
uses: aws-actions/configure-aws-credentials@v5
59+
with:
60+
role-to-assume: ${{ env.MAVEN_SNAPSHOTS_S3_ROLE }}
61+
aws-region: us-east-1
5262

5363
- name: Set commit ID
5464
id: set_commit
@@ -83,4 +93,4 @@ jobs:
8393
source ./.github/maven-publish-utils.sh
8494
8595
# Call the main function for async-query-core
86-
publish_async_query_core "${{ steps.extract_version.outputs.VERSION }}" "${{ steps.set_commit.outputs.commit_id }}"
96+
publish_async_query_core "${{ steps.extract_version.outputs.VERSION }}" "${{ steps.set_commit.outputs.commit_id }}"

.github/workflows/publish-grammar-files.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
push:
66
branches:
77
- main
8-
- 1.*
9-
- 2.*
8+
- '[0-9]+.[0-9]+'
9+
- '[0-9]+.x'
1010
paths:
1111
- 'language-grammar/src/main/antlr4/**'
1212
- 'language-grammar/build.gradle'
@@ -19,7 +19,6 @@ concurrency:
1919
cancel-in-progress: false
2020

2121
env:
22-
SNAPSHOT_REPO_URL: https://central.sonatype.com/repository/maven-snapshots/
2322
COMMIT_MAP_FILENAME: commit-history-language-grammar.json
2423

2524
jobs:
@@ -51,8 +50,19 @@ jobs:
5150
export-env: true
5251
env:
5352
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
54-
SONATYPE_USERNAME: op://opensearch-infra-secrets/maven-central-portal-credentials/username
55-
SONATYPE_PASSWORD: op://opensearch-infra-secrets/maven-central-portal-credentials/password
53+
MAVEN_SNAPSHOTS_S3_REPO: op://opensearch-infra-secrets/maven-snapshots-s3/repo
54+
MAVEN_SNAPSHOTS_S3_ROLE: op://opensearch-infra-secrets/maven-snapshots-s3/role
55+
56+
- name: Export SNAPSHOT_REPO_URL
57+
run: |
58+
snapshot_repo_url=${{ env.MAVEN_SNAPSHOTS_S3_REPO }}
59+
echo "SNAPSHOT_REPO_URL=$snapshot_repo_url" >> $GITHUB_ENV
60+
61+
- name: Configure AWS credentials
62+
uses: aws-actions/configure-aws-credentials@v5
63+
with:
64+
role-to-assume: ${{ env.MAVEN_SNAPSHOTS_S3_ROLE }}
65+
aws-region: us-east-1
5666

5767
- name: Set version
5868
id: set_version

.github/workflows/sql-test-and-build-workflow.yml

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ jobs:
179179
doctest/build/testclusters/docTestCluster-0/logs/*
180180
integ-test/build/testclusters/*/logs/*
181181
182-
bwc-tests:
182+
bwc-tests-rolling-upgrade:
183183
needs: Get-CI-Image-Tag
184184
runs-on: ubuntu-latest
185185
strategy:
@@ -190,37 +190,83 @@ jobs:
190190
options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }}
191191

192192
steps:
193-
- name: Run start commands
194-
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
195-
196-
- uses: actions/checkout@v4
197-
198-
- name: Set up JDK ${{ matrix.java }}
199-
uses: actions/setup-java@v4
200-
with:
201-
distribution: 'temurin'
202-
java-version: ${{ matrix.java }}
203-
204-
- name: Run backward compatibility tests
205-
run: |
206-
chown -R 1000:1000 `pwd`
207-
su `id -un 1000` -c "./scripts/bwctest.sh"
208-
209-
- name: Upload test reports
210-
if: ${{ always() }}
211-
uses: actions/upload-artifact@v4
212-
continue-on-error: true
213-
with:
214-
name: test-reports-ubuntu-latest-${{ matrix.java }}-bwc
215-
path: |
216-
sql/build/reports/**
217-
ppl/build/reports/**
218-
core/build/reports/**
219-
common/build/reports/**
220-
opensearch/build/reports/**
221-
integ-test/build/reports/**
222-
protocol/build/reports/**
223-
legacy/build/reports/**
224-
plugin/build/reports/**
225-
doctest/build/testclusters/docTestCluster-0/logs/*
226-
integ-test/build/testclusters/*/logs/*
193+
- name: Run start commands
194+
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
195+
196+
- uses: actions/checkout@v4
197+
198+
- name: Set up JDK ${{ matrix.java }}
199+
uses: actions/setup-java@v4
200+
with:
201+
distribution: 'temurin'
202+
java-version: ${{ matrix.java }}
203+
204+
- name: Run backward compatibility tests in rolling upgrade
205+
run: |
206+
chown -R 1000:1000 `pwd`
207+
su `id -un 1000` -c "./scripts/bwctest-rolling-upgrade.sh"
208+
209+
- name: Upload test reports
210+
if: ${{ always() }}
211+
uses: actions/upload-artifact@v4
212+
continue-on-error: true
213+
with:
214+
name: test-reports-ubuntu-latest-${{ matrix.java }}-bwc
215+
path: |
216+
sql/build/reports/**
217+
ppl/build/reports/**
218+
core/build/reports/**
219+
common/build/reports/**
220+
opensearch/build/reports/**
221+
integ-test/build/reports/**
222+
protocol/build/reports/**
223+
legacy/build/reports/**
224+
plugin/build/reports/**
225+
doctest/build/testclusters/docTestCluster-0/logs/*
226+
integ-test/build/testclusters/*/logs/*
227+
228+
bwc-tests-full-restart:
229+
needs: Get-CI-Image-Tag
230+
runs-on: ubuntu-latest
231+
strategy:
232+
matrix:
233+
java: [21, 24]
234+
container:
235+
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
236+
options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }}
237+
238+
steps:
239+
- name: Run start commands
240+
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
241+
242+
- uses: actions/checkout@v4
243+
244+
- name: Set up JDK ${{ matrix.java }}
245+
uses: actions/setup-java@v4
246+
with:
247+
distribution: 'temurin'
248+
java-version: ${{ matrix.java }}
249+
250+
- name: Run backward compatibility tests in full restart
251+
run: |
252+
chown -R 1000:1000 `pwd`
253+
su `id -un 1000` -c "./scripts/bwctest-full-restart.sh"
254+
255+
- name: Upload test reports
256+
if: ${{ always() }}
257+
uses: actions/upload-artifact@v4
258+
continue-on-error: true
259+
with:
260+
name: test-reports-ubuntu-latest-${{ matrix.java }}-bwc
261+
path: |
262+
sql/build/reports/**
263+
ppl/build/reports/**
264+
core/build/reports/**
265+
common/build/reports/**
266+
opensearch/build/reports/**
267+
integ-test/build/reports/**
268+
protocol/build/reports/**
269+
legacy/build/reports/**
270+
plugin/build/reports/**
271+
doctest/build/testclusters/docTestCluster-0/logs/*
272+
integ-test/build/testclusters/*/logs/*

DEVELOPER_GUIDE.rst

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ Here are other files and sub-folders that you are likely to touch:
173173
- ``build.gradle``: Gradle build script.
174174
- ``docs``: documentation for developers and reference manual for users.
175175
- ``doc-test``: code that run .rst docs in ``docs`` folder by Python doctest library.
176-
- ``language-grammar``: centralized package for ANTLR grammar files. See `Language Grammar Package`_ for details.
177176

178177
Note that other related project code has already merged into this single repository together:
179178

@@ -444,29 +443,3 @@ with an appropriate label `backport <backport-branch-name>` is merged to main wi
444443
PR. For example, if a PR on main needs to be backported to `1.x` branch, add a label `backport 1.x` to the PR and make sure the
445444
backport workflow runs on the PR along with other checks. Once this PR is merged to main, the workflow will create a backport PR
446445
to the `1.x` branch.
447-
448-
Language Grammar Package
449-
========================
450-
451-
The ``language-grammar`` package serves as a centralized repository for all ANTLR grammar files used throughout the OpenSearch SQL project. This package contains the definitive versions of grammar files for:
452-
453-
- SQL parsing (``OpenSearchSQLParser.g4``, ``OpenSearchSQLLexer.g4``)
454-
- PPL parsing (``OpenSearchPPLParser.g4``, ``OpenSearchPPLLexer.g4``)
455-
- Legacy SQL parsing (``OpenSearchLegacySqlParser.g4``, ``OpenSearchLegacySqlLexer.g4``)
456-
- Spark SQL extensions (``SparkSqlBase.g4``, ``FlintSparkSqlExtensions.g4``, ``SqlBaseParser.g4``, ``SqlBaseLexer.g4``)
457-
458-
Purpose
459-
-------
460-
461-
The language-grammar package enables sharing of grammar files between the main SQL repository and the Spark repository, ensuring consistency and reducing duplication. Once updated, the package automatically triggers CI to upload the new version to Maven Central for consumption by other projects.
462-
463-
Updating Grammar Files
464-
----------------------
465-
466-
When grammar files are modified in their respective modules (``sql/``, ``ppl/``, ``legacy/``, ``async-query-core/``), they must be manually copied to the ``language-grammar/src/main/antlr4/`` directory.
467-
468-
**Workflow:**
469-
470-
1. Modify grammar files in their source locations (e.g., ``sql/src/main/antlr/``)
471-
2. Copy updated files to ``language-grammar/src/main/antlr4/``
472-
3. Commit changes to trigger automatic Maven publication via CI

api/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Unified Query API
2+
3+
This module provides a high-level integration layer for the Calcite-based query engine, enabling external systems such as Apache Spark or command-line tools to parse and analyze queries without exposing low-level internals.
4+
5+
## Overview
6+
7+
The `UnifiedQueryPlanner` serves as the primary entry point for external consumers. It accepts PPL (Piped Processing Language) queries and returns Calcite `RelNode` logical plans as intermediate representation.
8+
9+
## Usage
10+
11+
Use the declarative, fluent builder API to initialize the `UnifiedQueryPlanner`.
12+
13+
```java
14+
UnifiedQueryPlanner planner = UnifiedQueryPlanner.builder()
15+
.language(QueryType.PPL)
16+
.catalog("opensearch", schema)
17+
.defaultNamespace("opensearch")
18+
.cacheMetadata(true)
19+
.build();
20+
21+
RelNode plan = planner.plan("source = opensearch.test");
22+
```
23+
24+
## Development & Testing
25+
26+
A set of unit tests is provided to validate planner behavior.
27+
28+
To run tests:
29+
30+
```
31+
./gradlew :api:test
32+
```
33+
34+
## Integration Guide
35+
36+
This guide walks through how to integrate unified query planner into your application.
37+
38+
### Step 1: Add Dependency
39+
40+
The module is currently published as a snapshot to the AWS Sonatype Snapshots repository. To include it as a dependency in your project, add the following to your `pom.xml` or `build.gradle`:
41+
42+
```xml
43+
<dependency>
44+
<groupId>org.opensearch.query</groupId>
45+
<artifactId>unified-query-api</artifactId>
46+
<version>YOUR_VERSION_HERE</version>
47+
</dependency>
48+
```
49+
50+
### Step 2: Implement a Calcite Schema
51+
52+
You must implement the Calcite `Schema` interface and register them using the fluent `catalog()` method on the builder.
53+
54+
```java
55+
public class MySchema extends AbstractSchema {
56+
@Override
57+
protected Map<String, Table> getTableMap() {
58+
return Map.of(
59+
"test_table",
60+
new AbstractTable() {
61+
@Override
62+
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
63+
return typeFactory.createStructType(
64+
List.of(typeFactory.createSqlType(SqlTypeName.INTEGER)),
65+
List.of("id"));
66+
}
67+
});
68+
}
69+
}
70+
```
71+
72+
## Future Work
73+
74+
- Expand support to SQL language.
75+
- Extend planner to generate optimized physical plans using Calcite's optimization frameworks.

0 commit comments

Comments
 (0)