Skip to content

Commit 1be0c6a

Browse files
authored
Merge branch 'main' into feature/headtop-limit
Signed-off-by: Simeon Widdis <[email protected]>
2 parents d70dc77 + 9143a44 commit 1be0c6a

File tree

459 files changed

+19107
-3346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

459 files changed

+19107
-3346
lines changed

.github/workflows/integ-tests-with-security.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
paths:
1010
- 'integ-test/**'
1111
- '.github/workflows/integ-tests-with-security.yml'
12+
merge_group:
1213

1314
jobs:
1415
Get-CI-Image-Tag:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
- '**/*.jar'
1717
- '**/*.pom'
1818
- '.github/workflows/sql-test-and-build-workflow.yml'
19+
merge_group:
1920

2021
jobs:
2122
Get-CI-Image-Tag:

.pre-commit-config.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
repos:
22
- repo: local
33
hooks:
4+
- id: spotless-format
5+
name: Spotless Format
6+
entry: bash -c './gradlew spotlessApply && git add -u'
7+
language: system
8+
pass_filenames: false
49
- id: spotless-check
5-
name: Spotless Check
6-
entry: ./gradlew spotlessCheck
10+
name: Spotless Post-format Check
11+
entry: bash -c './gradlew spotlessCheck'
712
language: system
813
pass_filenames: false

DEVELOPER_GUIDE.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ 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.
176177

177178
Note that other related project code has already merged into this single repository together:
178179

@@ -441,3 +442,29 @@ with an appropriate label `backport <backport-branch-name>` is merged to main wi
441442
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
442443
backport workflow runs on the PR along with other checks. Once this PR is merged to main, the workflow will create a backport PR
443444
to the `1.x` branch.
445+
446+
Language Grammar Package
447+
========================
448+
449+
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:
450+
451+
- SQL parsing (``OpenSearchSQLParser.g4``, ``OpenSearchSQLLexer.g4``)
452+
- PPL parsing (``OpenSearchPPLParser.g4``, ``OpenSearchPPLLexer.g4``)
453+
- Legacy SQL parsing (``OpenSearchLegacySqlParser.g4``, ``OpenSearchLegacySqlLexer.g4``)
454+
- Spark SQL extensions (``SparkSqlBase.g4``, ``FlintSparkSqlExtensions.g4``, ``SqlBaseParser.g4``, ``SqlBaseLexer.g4``)
455+
456+
Purpose
457+
-------
458+
459+
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.
460+
461+
Updating Grammar Files
462+
----------------------
463+
464+
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.
465+
466+
**Workflow:**
467+
468+
1. Modify grammar files in their source locations (e.g., ``sql/src/main/antlr/``)
469+
2. Copy updated files to ``language-grammar/src/main/antlr4/``
470+
3. Commit changes to trigger automatic Maven publication via CI

async-query-core/src/main/java/org/opensearch/sql/spark/rest/model/LangType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
/** Language type accepted in async query apis. */
99
public enum LangType {
1010
SQL("sql"),
11-
PPL("ppl");
11+
PPL("ppl"),
12+
PROMQL("promql");
1213
private final String text;
1314

1415
LangType(String text) {

core/src/main/java/org/opensearch/sql/analysis/Analyzer.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
import org.opensearch.sql.ast.tree.Rename;
8787
import org.opensearch.sql.ast.tree.Reverse;
8888
import org.opensearch.sql.ast.tree.Rex;
89+
import org.opensearch.sql.ast.tree.SPath;
8990
import org.opensearch.sql.ast.tree.Search;
9091
import org.opensearch.sql.ast.tree.Sort;
9192
import org.opensearch.sql.ast.tree.Sort.SortOption;
@@ -95,6 +96,7 @@
9596
import org.opensearch.sql.ast.tree.Trendline;
9697
import org.opensearch.sql.ast.tree.UnresolvedPlan;
9798
import org.opensearch.sql.ast.tree.Values;
99+
import org.opensearch.sql.ast.tree.Window;
98100
import org.opensearch.sql.common.antlr.SyntaxCheckException;
99101
import org.opensearch.sql.data.model.ExprMissingValue;
100102
import org.opensearch.sql.data.type.ExprCoreType;
@@ -755,11 +757,21 @@ public LogicalPlan visitReverse(Reverse node, AnalysisContext context) {
755757
throw getOnlyForCalciteException("Reverse");
756758
}
757759

760+
@Override
761+
public LogicalPlan visitSpath(SPath node, AnalysisContext context) {
762+
throw getOnlyForCalciteException("Spath");
763+
}
764+
758765
@Override
759766
public LogicalPlan visitTimechart(Timechart node, AnalysisContext context) {
760767
throw getOnlyForCalciteException("Timechart");
761768
}
762769

770+
@Override
771+
public LogicalPlan visitWindow(Window node, AnalysisContext context) {
772+
throw getOnlyForCalciteException("Window");
773+
}
774+
763775
@Override
764776
public LogicalPlan visitRegex(Regex node, AnalysisContext context) {
765777
throw getOnlyForCalciteException("Regex");

core/src/main/java/org/opensearch/sql/analysis/ExpressionAnalyzer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.opensearch.sql.ast.expression.HighlightFunction;
3939
import org.opensearch.sql.ast.expression.In;
4040
import org.opensearch.sql.ast.expression.Interval;
41+
import org.opensearch.sql.ast.expression.LambdaFunction;
4142
import org.opensearch.sql.ast.expression.Literal;
4243
import org.opensearch.sql.ast.expression.Not;
4344
import org.opensearch.sql.ast.expression.Or;
@@ -479,6 +480,11 @@ public Expression visitInSubquery(InSubquery node, AnalysisContext context) {
479480
throw getOnlyForCalciteException("Subsearch");
480481
}
481482

483+
@Override
484+
public Expression visitLambdaFunction(LambdaFunction node, AnalysisContext context) {
485+
throw getOnlyForCalciteException("Lambda function");
486+
}
487+
482488
/**
483489
* If QualifiedName is actually a reserved metadata field, return the expr type associated with
484490
* the metadata field.

core/src/main/java/org/opensearch/sql/ast/expression/Literal.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.google.common.collect.ImmutableList;
99
import java.math.BigDecimal;
10+
import java.text.DecimalFormat;
1011
import java.util.List;
1112
import lombok.EqualsAndHashCode;
1213
import lombok.Getter;
@@ -25,7 +26,21 @@ public class Literal extends UnresolvedExpression {
2526

2627
public Literal(Object value, DataType dataType) {
2728
if (dataType == DataType.DECIMAL && value instanceof Double) {
28-
this.value = BigDecimal.valueOf((Double) value);
29+
// This branch is only used in testing for backward compatibility:
30+
// We accept decimal literal by Literal(double, DataType.DECIMAL).
31+
// Some double values such as 0.0001 will be converted to string "1.0E-4" and finally
32+
// generate decimal 0.00010. So here we parse a decimal text to Double then convert it
33+
// to BigDecimal as well.
34+
// In v2, a decimal literal will be converted back to double in resolving expression
35+
// via ExprDoubleValue.
36+
// In v3, a decimal literal will be kept in Calcite RexNode and converted back to double
37+
// in runtime.
38+
DecimalFormat df = new DecimalFormat();
39+
df.setMaximumFractionDigits(38);
40+
df.setMinimumFractionDigits(1);
41+
df.setGroupingUsed(false);
42+
String plain = df.format(value);
43+
this.value = new BigDecimal(plain);
2944
} else {
3045
this.value = value;
3146
}

core/src/main/java/org/opensearch/sql/ast/expression/SpanUnit.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public enum SpanUnit {
4242
SPAN_UNITS = builder.add(SpanUnit.values()).build();
4343
}
4444

45+
/** Util method to check if the unit is time unit. */
46+
public static boolean isTimeUnit(SpanUnit unit) {
47+
return unit != UNKNOWN && unit != NONE;
48+
}
49+
4550
/** Util method to get span unit given the unit name. */
4651
public static SpanUnit of(String unit) {
4752
switch (unit) {

0 commit comments

Comments
 (0)