Skip to content

Commit 2d09610

Browse files
committed
Merge remote-tracking branch 'origin/main' into issues/4136
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
2 parents 4c20af1 + ca4d6c1 commit 2d09610

103 files changed

Lines changed: 5016 additions & 305 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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: 📃 Documentation issue
3+
about: Need docs? Create an issue to request or add new documentation.
4+
title: '[DOC]'
5+
labels: 'untriaged, documentation'
6+
assignees: ''
7+
---
8+
9+
**What do you want to do?**
10+
11+
- [ ] Request a change to existing documentation
12+
- [ ] Add new documentation
13+
- [ ] Report a technical problem with the documentation
14+
- [ ] Other
15+
16+
**Tell us about your request.** Provide a summary of the request.
17+
18+
**Version:** List the OpenSearch version to which this issue applies, e.g. 2.14, 2.12--2.14, or all.
19+
20+
**What other resources are available?** Provide links to related issues, POCs, steps for testing, etc.

DEVELOPER_GUIDE.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ Building and Running Tests
225225
Gradle Build
226226
------------
227227

228-
Most of the time you just need to run ./gradlew build which will make sure you pass all checks and testing. While you're developing, you may want to run specific Gradle task only. In this case, you can run ./gradlew with task name which only triggers the task along with those it depends on. Here is a list for common tasks:
228+
Most of the time you just need to run ``./gradlew build`` which will make sure you pass all checks and testing. While you're developing, you may want to run specific Gradle task only. In this case, you can run ./gradlew with task name which only triggers the task along with those it depends on. Here is a list for common tasks:
229+
230+
For faster local iterations, the build can skip integration and doctests. ``./gradlew build --parallel -x integTest -x doctest``.
229231

230232
.. list-table::
231233
:widths: 30 50

async-query-core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ spotless {
8585
}
8686

8787
test {
88+
maxParallelForks = Runtime.runtime.availableProcessors()
8889
useJUnitPlatform()
8990
testLogging {
9091
events "skipped", "failed"

async-query/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ dependencies {
5353
}
5454

5555
test {
56+
maxParallelForks = Runtime.runtime.availableProcessors()
5657
useJUnitPlatform {
5758
includeEngines("junit-jupiter")
5859
}
@@ -62,6 +63,7 @@ test {
6263
}
6364
}
6465
task junit4(type: Test) {
66+
maxParallelForks = Runtime.runtime.availableProcessors()
6567
useJUnitPlatform {
6668
includeEngines("junit-vintage")
6769
}

core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ spotless {
9494
}
9595

9696
test {
97+
maxParallelForks = Runtime.runtime.availableProcessors()
9798
useJUnitPlatform()
9899
testLogging {
99100
events "skipped", "failed"

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

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import static org.opensearch.sql.ast.tree.Sort.NullOrder.NULL_LAST;
1111
import static org.opensearch.sql.ast.tree.Sort.SortOrder.ASC;
1212
import static org.opensearch.sql.ast.tree.Sort.SortOrder.DESC;
13-
import static org.opensearch.sql.common.setting.Settings.Key.CALCITE_ENGINE_ENABLED;
13+
import static org.opensearch.sql.calcite.utils.CalciteUtils.getOnlyForCalciteException;
1414
import static org.opensearch.sql.data.type.ExprCoreType.DATE;
1515
import static org.opensearch.sql.data.type.ExprCoreType.STRUCT;
1616
import static org.opensearch.sql.data.type.ExprCoreType.TIME;
@@ -79,6 +79,7 @@
7979
import org.opensearch.sql.ast.tree.Patterns;
8080
import org.opensearch.sql.ast.tree.Project;
8181
import org.opensearch.sql.ast.tree.RareTopN;
82+
import org.opensearch.sql.ast.tree.Regex;
8283
import org.opensearch.sql.ast.tree.Relation;
8384
import org.opensearch.sql.ast.tree.RelationSubquery;
8485
import org.opensearch.sql.ast.tree.Rename;
@@ -87,6 +88,7 @@
8788
import org.opensearch.sql.ast.tree.Sort.SortOption;
8889
import org.opensearch.sql.ast.tree.SubqueryAlias;
8990
import org.opensearch.sql.ast.tree.TableFunction;
91+
import org.opensearch.sql.ast.tree.Timechart;
9092
import org.opensearch.sql.ast.tree.Trendline;
9193
import org.opensearch.sql.ast.tree.UnresolvedPlan;
9294
import org.opensearch.sql.ast.tree.Values;
@@ -181,8 +183,7 @@ public LogicalPlan visitSubqueryAlias(SubqueryAlias node, AnalysisContext contex
181183
STRUCT);
182184
return child;
183185
} else {
184-
throw new UnsupportedOperationException(
185-
"Subsearch is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
186+
throw getOnlyForCalciteException("Subsearch");
186187
}
187188
}
188189

@@ -672,14 +673,12 @@ public LogicalPlan visitML(ML node, AnalysisContext context) {
672673

673674
@Override
674675
public LogicalPlan visitBin(Bin node, AnalysisContext context) {
675-
throw new UnsupportedOperationException(
676-
"Bin command is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
676+
throw getOnlyForCalciteException("Bin");
677677
}
678678

679679
@Override
680680
public LogicalPlan visitExpand(Expand expand, AnalysisContext context) {
681-
throw new UnsupportedOperationException(
682-
"Expand is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
681+
throw getOnlyForCalciteException("Expand");
683682
}
684683

685684
/** Build {@link LogicalTrendline} for Trendline command. */
@@ -733,14 +732,22 @@ public LogicalPlan visitTrendline(Trendline node, AnalysisContext context) {
733732

734733
@Override
735734
public LogicalPlan visitFlatten(Flatten node, AnalysisContext context) {
736-
throw new UnsupportedOperationException(
737-
"FLATTEN is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
735+
throw getOnlyForCalciteException("Flatten");
738736
}
739737

740738
@Override
741739
public LogicalPlan visitReverse(Reverse node, AnalysisContext context) {
742-
throw new UnsupportedOperationException(
743-
"REVERSE is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
740+
throw getOnlyForCalciteException("Reverse");
741+
}
742+
743+
@Override
744+
public LogicalPlan visitTimechart(Timechart node, AnalysisContext context) {
745+
throw getOnlyForCalciteException("Timechart");
746+
}
747+
748+
@Override
749+
public LogicalPlan visitRegex(Regex node, AnalysisContext context) {
750+
throw getOnlyForCalciteException("Regex");
744751
}
745752

746753
@Override
@@ -763,20 +770,17 @@ public LogicalPlan visitCloseCursor(CloseCursor closeCursor, AnalysisContext con
763770

764771
@Override
765772
public LogicalPlan visitJoin(Join node, AnalysisContext context) {
766-
throw new UnsupportedOperationException(
767-
"Join is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
773+
throw getOnlyForCalciteException("Join");
768774
}
769775

770776
@Override
771777
public LogicalPlan visitLookup(Lookup node, AnalysisContext context) {
772-
throw new UnsupportedOperationException(
773-
"Lookup is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
778+
throw getOnlyForCalciteException("Lookup");
774779
}
775780

776781
@Override
777782
public LogicalPlan visitAppendCol(AppendCol node, AnalysisContext context) {
778-
throw new UnsupportedOperationException(
779-
"AppendCol is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
783+
throw getOnlyForCalciteException("Appendcol");
780784
}
781785

782786
private LogicalSort buildSort(

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import static org.opensearch.sql.ast.dsl.AstDSL.and;
99
import static org.opensearch.sql.ast.dsl.AstDSL.compare;
10-
import static org.opensearch.sql.common.setting.Settings.Key.CALCITE_ENGINE_ENABLED;
10+
import static org.opensearch.sql.calcite.utils.CalciteUtils.getOnlyForCalciteException;
1111

1212
import com.google.common.collect.ImmutableList;
1313
import com.google.common.collect.ImmutableMap;
@@ -435,20 +435,17 @@ public Expression visitArgument(Argument node, AnalysisContext context) {
435435

436436
@Override
437437
public Expression visitScalarSubquery(ScalarSubquery node, AnalysisContext context) {
438-
throw new UnsupportedOperationException(
439-
"Subsearch is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
438+
throw getOnlyForCalciteException("Subsearch");
440439
}
441440

442441
@Override
443442
public Expression visitExistsSubquery(ExistsSubquery node, AnalysisContext context) {
444-
throw new UnsupportedOperationException(
445-
"Subsearch is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
443+
throw getOnlyForCalciteException("Subsearch");
446444
}
447445

448446
@Override
449447
public Expression visitInSubquery(InSubquery node, AnalysisContext context) {
450-
throw new UnsupportedOperationException(
451-
"Subsearch is supported only when " + CALCITE_ENGINE_ENABLED.getKeyValue() + "=true");
448+
throw getOnlyForCalciteException("Subsearch");
452449
}
453450

454451
/**

core/src/main/java/org/opensearch/sql/ast/AbstractNodeVisitor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.opensearch.sql.ast.tree.Patterns;
6868
import org.opensearch.sql.ast.tree.Project;
6969
import org.opensearch.sql.ast.tree.RareTopN;
70+
import org.opensearch.sql.ast.tree.Regex;
7071
import org.opensearch.sql.ast.tree.Relation;
7172
import org.opensearch.sql.ast.tree.RelationSubquery;
7273
import org.opensearch.sql.ast.tree.Rename;
@@ -75,6 +76,7 @@
7576
import org.opensearch.sql.ast.tree.Sort;
7677
import org.opensearch.sql.ast.tree.SubqueryAlias;
7778
import org.opensearch.sql.ast.tree.TableFunction;
79+
import org.opensearch.sql.ast.tree.Timechart;
7880
import org.opensearch.sql.ast.tree.Trendline;
7981
import org.opensearch.sql.ast.tree.Values;
8082
import org.opensearch.sql.ast.tree.Window;
@@ -259,6 +261,14 @@ public T visitReverse(Reverse node, C context) {
259261
return visitChildren(node, context);
260262
}
261263

264+
public T visitTimechart(Timechart node, C context) {
265+
return visitChildren(node, context);
266+
}
267+
268+
public T visitRegex(Regex node, C context) {
269+
return visitChildren(node, context);
270+
}
271+
262272
public T visitLambdaFunction(LambdaFunction node, C context) {
263273
return visitChildren(node, context);
264274
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.sql.ast.tree;
7+
8+
import com.google.common.collect.ImmutableList;
9+
import java.util.List;
10+
import lombok.EqualsAndHashCode;
11+
import lombok.Getter;
12+
import lombok.Setter;
13+
import lombok.ToString;
14+
import org.opensearch.sql.ast.AbstractNodeVisitor;
15+
import org.opensearch.sql.ast.expression.Literal;
16+
import org.opensearch.sql.ast.expression.UnresolvedExpression;
17+
18+
@Getter
19+
@ToString
20+
@EqualsAndHashCode(callSuper = false)
21+
public class Regex extends UnresolvedPlan {
22+
public static final String EQUALS_OPERATOR = "=";
23+
24+
public static final String NOT_EQUALS_OPERATOR = "!=";
25+
26+
private final UnresolvedExpression field;
27+
28+
private final boolean negated;
29+
30+
private final Literal pattern;
31+
32+
@Setter private UnresolvedPlan child;
33+
34+
public Regex(UnresolvedExpression field, boolean negated, Literal pattern) {
35+
this.field = field;
36+
this.negated = negated;
37+
this.pattern = pattern;
38+
}
39+
40+
@Override
41+
public Regex attach(UnresolvedPlan child) {
42+
this.child = child;
43+
return this;
44+
}
45+
46+
@Override
47+
public List<UnresolvedPlan> getChild() {
48+
return this.child == null ? ImmutableList.of() : ImmutableList.of(this.child);
49+
}
50+
51+
@Override
52+
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
53+
return nodeVisitor.visitRegex(this, context);
54+
}
55+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.sql.ast.tree;
7+
8+
import com.google.common.collect.ImmutableList;
9+
import java.util.List;
10+
import lombok.AllArgsConstructor;
11+
import lombok.EqualsAndHashCode;
12+
import lombok.Getter;
13+
import lombok.ToString;
14+
import org.opensearch.sql.ast.AbstractNodeVisitor;
15+
import org.opensearch.sql.ast.expression.UnresolvedExpression;
16+
17+
/** AST node represent Timechart operation. */
18+
@Getter
19+
@ToString
20+
@EqualsAndHashCode(callSuper = false)
21+
@AllArgsConstructor
22+
@lombok.Builder(toBuilder = true)
23+
public class Timechart extends UnresolvedPlan {
24+
private UnresolvedPlan child;
25+
private UnresolvedExpression binExpression;
26+
private UnresolvedExpression aggregateFunction;
27+
private UnresolvedExpression byField;
28+
private Integer limit;
29+
private Boolean useOther;
30+
31+
public Timechart(UnresolvedPlan child, UnresolvedExpression aggregateFunction) {
32+
this(child, null, aggregateFunction, null, null, true);
33+
}
34+
35+
public Timechart span(UnresolvedExpression binExpression) {
36+
return toBuilder().binExpression(binExpression).build();
37+
}
38+
39+
public Timechart by(UnresolvedExpression byField) {
40+
return toBuilder().byField(byField).build();
41+
}
42+
43+
public Timechart limit(Integer limit) {
44+
return toBuilder().limit(limit).build();
45+
}
46+
47+
public Timechart useOther(Boolean useOther) {
48+
return toBuilder().useOther(useOther).build();
49+
}
50+
51+
@Override
52+
public Timechart attach(UnresolvedPlan child) {
53+
return toBuilder().child(child).build();
54+
}
55+
56+
@Override
57+
public List<UnresolvedPlan> getChild() {
58+
return ImmutableList.of(child);
59+
}
60+
61+
@Override
62+
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
63+
return nodeVisitor.visitTimechart(this, context);
64+
}
65+
}

0 commit comments

Comments
 (0)