Skip to content

Commit 0c5cb73

Browse files
committed
Merge remote-tracking branch 'upstream/main' into big5
2 parents f303f36 + d7bf644 commit 0c5cb73

46 files changed

Lines changed: 960 additions & 99 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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Enforce PR labels
2+
3+
on:
4+
pull_request:
5+
types: [labeled, unlabeled, opened, edited, synchronize]
6+
jobs:
7+
enforce-label:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: yogevbd/enforce-label-action@2.1.0
11+
with:
12+
REQUIRED_LABELS_ANY: "breaking,feature,enhancement,bug,infrastructure,dependencies,documentation,maintenance,skip-changelog"
13+
REQUIRED_LABELS_ANY_DESCRIPTION: "A release label is required: ['breaking', 'bug', 'dependencies', 'documentation', 'enhancement', 'feature', 'infrastructure', 'maintenance', 'skip-changelog']"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public enum SpanUnit {
4545
/** Util method to get span unit given the unit name. */
4646
public static SpanUnit of(String unit) {
4747
switch (unit) {
48+
case null:
4849
case "":
4950
return NONE;
5051
case "M":

core/src/main/java/org/opensearch/sql/expression/function/udf/SpanFunction.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ public SqlReturnTypeInference getReturnTypeInference() {
5151
public UDFOperandMetadata getOperandMetadata() {
5252
return UDFOperandMetadata.wrap(
5353
(CompositeOperandTypeChecker)
54-
OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.INTEGER, SqlTypeFamily.STRING)
54+
OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.NUMERIC, SqlTypeFamily.STRING)
5555
.or(
5656
OperandTypes.family(
57-
SqlTypeFamily.DATETIME, SqlTypeFamily.INTEGER, SqlTypeFamily.STRING))
57+
SqlTypeFamily.DATETIME, SqlTypeFamily.NUMERIC, SqlTypeFamily.STRING))
58+
// TODO: numeric span should support decimal as its interval
5859
.or(
5960
OperandTypes.family(
60-
SqlTypeFamily.INTEGER, SqlTypeFamily.INTEGER, SqlTypeFamily.ANY)));
61+
SqlTypeFamily.NUMERIC, SqlTypeFamily.INTEGER, SqlTypeFamily.ANY)));
6162
}
6263

6364
public static class SpanImplementor implements NotNullImplementor {

docs/dev/intro-v3-engine.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PPL Engine V3 (for 3.0.0-beta)
1+
# PPL Engine V3 (for 3.0.0)
22

33
---
44
## 1. Motivations
@@ -24,7 +24,7 @@ Find more details in [V3 Architecture](./intro-v3-architecture.md).
2424
---
2525
## 2. What's New
2626

27-
In the initial release of the V3 engine (3.0.0-beta), the main new features focus on enhancing the PPL language while maintaining maximum compatibility with V2 behavior.
27+
In the initial release of the V3 engine (3.0.0), the main new features focus on enhancing the PPL language while maintaining maximum compatibility with V2 behavior.
2828

2929
* **[Join](../user/ppl/cmd/join.rst) Command**
3030
* **[Lookup](../user/ppl/cmd/lookup.rst) Command**
@@ -35,7 +35,7 @@ In the initial release of the V3 engine (3.0.0-beta), the main new features focu
3535

3636
### 3.1 Breaking Changes
3737

38-
Because of implementation changed internally, following behaviors are changed from 3.0.0-beta. (Behaviors in V3 is correct)
38+
Because of implementation changed internally, following behaviors are changed from 3.0.0. (Behaviors in V3 is correct)
3939

4040
| Item | V2 | V3 |
4141
|:------------------------------------------------:|:---------:|:--------------------:|
@@ -51,7 +51,7 @@ Because of implementation changed internally, following behaviors are changed fr
5151

5252
### 3.2 Fallback Mechanism
5353

54-
As v3 engine is experimental in 3.0.0-beta, not all PPL commands could work under this new engine. Those unsupported queries will be forwarded to V2 engine by fallback mechanism. To avoid impact on your side, normally you won't see any difference in a query response. If you want to check if and why your query falls back to be handled by V2 engine, please check OpenSearch log for "Fallback to V2 query engine since ...".
54+
As v3 engine is experimental in 3.0.0, not all PPL commands could work under this new engine. Those unsupported queries will be forwarded to V2 engine by fallback mechanism. To avoid impact on your side, normally you won't see any difference in a query response. If you want to check if and why your query falls back to be handled by V2 engine, please check OpenSearch log for "Fallback to V2 query engine since ...".
5555

5656
### 3.3 Limitations
5757

@@ -66,24 +66,12 @@ For the following functionalities in V3 engine, the query will be forwarded to t
6666

6767
#### Unsupported functionalities
6868
- All SQL queries
69-
- `trendline`
70-
- `show datasource`
71-
- `explain`
72-
- `describe`
73-
- `top` and `rare`
74-
- `fillnull`
75-
- `patterns`
7669
- `dedup` with `consecutive=true`
7770
- Search relevant commands
7871
- AD
7972
- ML
8073
- Kmeans
8174
- Commands with `fetch_size` parameter
82-
- query with metadata fields, `_id`, `_doc`, etc.
83-
- Json relevant functions
84-
- cast to json
85-
- json
86-
- json_valid
8775
- Search relevant functions
8876
- match
8977
- match_phrase
@@ -105,6 +93,5 @@ If you're interested in the new query engine, please find more details in [V3 Ar
10593
The following items are on our roadmap with high priority:
10694
- Resolve the [V3 limitation](#33-limitations).
10795
- Advancing pushdown optimization and benchmarking
108-
- Backport to 2.19.x
10996
- Unified the PPL syntax between [PPL-on-OpenSearch](https://github.com/opensearch-project/sql/blob/main/ppl/src/main/antlr/OpenSearchPPLParser.g4) and [PPL-on-Spark](https://github.com/opensearch-project/opensearch-spark/blob/main/ppl-spark-integration/src/main/antlr4/OpenSearchPPLParser.g4)
11097
- Support more DSL aggregation

docs/user/limitations/limitations.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,31 @@ The response in JSON format is::
130130
},
131131
"status": 400
132132
}
133+
134+
Limitations on Calcite Engine
135+
=============================
136+
137+
Since 3.0.0, we introduce Apache Calcite as an experimental query engine. Please see `introduce v3 engine <../../../dev/intro-v3-engine.md>`_.
138+
For the following functionalities, the query will be forwarded to the V2 query engine.
139+
140+
* All SQL queries
141+
142+
* ``dedup`` with ``consecutive=true``
143+
144+
* Search relevant commands
145+
146+
* AD
147+
* ML
148+
* Kmeans
149+
150+
* Commands with ``fetch_size`` parameter
151+
152+
* Search relevant functions
153+
154+
* match
155+
* match_phrase
156+
* match_bool_prefix
157+
* match_phrase_prefix
158+
* simple_query_string
159+
* query_string
160+
* multi_match

docs/user/ppl/limitations/limitations.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,31 @@ plugins.query.field_type_tolerance setting is enabled, the SQL/PPL plugin will h
8484
scalar data types, allowing basic queries (e.g., source = tbl | where condition). However, using multi-value
8585
fields in expressions or functions will result in exceptions. If this setting is disabled or absent, only the
8686
first element of an array is returned, preserving the default behavior.
87+
88+
Unsupported Functionalities in Calcite Engine
89+
=============================================
90+
91+
Since 3.0.0, we introduce Apache Calcite as an experimental query engine. Please see `introduce v3 engine <../../../dev/intro-v3-engine.md>`_.
92+
For the following functionalities, the query will be forwarded to the V2 query engine.
93+
94+
* All SQL queries
95+
96+
* ``dedup`` with ``consecutive=true``
97+
98+
* Search relevant commands
99+
100+
* AD
101+
* ML
102+
* Kmeans
103+
104+
* Commands with ``fetch_size`` parameter
105+
106+
* Search relevant functions
107+
108+
* match
109+
* match_phrase
110+
* match_bool_prefix
111+
* match_phrase_prefix
112+
* simple_query_string
113+
* query_string
114+
* multi_match

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteExplainIT.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ public void init() throws Exception {
2020
@Override
2121
@Ignore("test only in v2")
2222
public void testExplainModeUnsupportedInV2() throws IOException {}
23+
24+
@Override
25+
public void testExplain() throws IOException {
26+
super.testExplain();
27+
}
2328
}

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLAggregationIT.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,13 @@ public void testCountBySpanForCustomFormats() throws IOException {
501501
actual,
502502
schema("timestamp_span", "timestamp"),
503503
schema("count(custom_no_delimiter_ts)", "bigint"));
504-
verifyDataRows(actual, rows(1, "1961-04-12 10:00:00"), rows(1, "1984-10-20 15:00:00"));
504+
// TODO: Span has different behavior between pushdown and non-pushdown for timestamp before
505+
// 1971. V2 engine will have the same issue.
506+
// https://github.com/opensearch-project/sql/issues/3827
507+
verifyDataRows(
508+
actual,
509+
rows(1, isPushdownEnabled() ? "1961-04-12 09:00:00" : "1961-04-12 10:00:00"),
510+
rows(1, "1984-10-20 15:00:00"));
505511

506512
actual =
507513
executeQuery(

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLSortIT.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,22 @@ public void testSortWithNullValue() throws IOException {
217217
rows("Elinor", null),
218218
rows("Virginia", null));
219219
}
220+
221+
@Test
222+
public void testSortDate() throws IOException {
223+
JSONObject result =
224+
executeQuery(
225+
String.format(
226+
"source=%s | sort birthdate | fields firstname, birthdate", TEST_INDEX_BANK));
227+
verifySchema(result, schema("firstname", "string"), schema("birthdate", "timestamp"));
228+
verifyDataRowsInOrder(
229+
result,
230+
rows("Amber JOHnny", "2017-10-23 00:00:00"),
231+
rows("Hattie", "2017-11-20 00:00:00"),
232+
rows("Nanette", "2018-06-23 00:00:00"),
233+
rows("Elinor", "2018-06-27 00:00:00"),
234+
rows("Dillard", "2018-08-11 00:00:00"),
235+
rows("Virginia", "2018-08-19 00:00:00"),
236+
rows("Dale", "2018-11-13 23:33:20"));
237+
}
220238
}

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteSortCommandIT.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55

66
package org.opensearch.sql.calcite.remote;
77

8+
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
9+
import static org.opensearch.sql.util.MatcherUtils.rows;
10+
import static org.opensearch.sql.util.MatcherUtils.verifyOrder;
11+
12+
import java.io.IOException;
13+
import org.json.JSONObject;
14+
import org.junit.Test;
815
import org.opensearch.sql.ppl.SortCommandIT;
916

1017
public class CalciteSortCommandIT extends SortCommandIT {
@@ -14,4 +21,12 @@ public void init() throws Exception {
1421
enableCalcite();
1522
disallowCalciteFallback();
1623
}
24+
25+
// TODO: Move this test to SortCommandIT once head-then-sort is fixed in v2.
26+
@Test
27+
public void testHeadThenSort() throws IOException {
28+
JSONObject result =
29+
executeQuery(String.format("source=%s | head 2 | sort age | fields age", TEST_INDEX_BANK));
30+
verifyOrder(result, rows(32), rows(36));
31+
}
1732
}

0 commit comments

Comments
 (0)