Skip to content

Commit f3ad080

Browse files
committed
Revert SPL settings
Signed-off-by: Lantao Jin <ltjin@amazon.com>
1 parent 5aa3206 commit f3ad080

21 files changed

Lines changed: 361 additions & 361 deletions

File tree

async-query-core/src/main/java/org/opensearch/sql/spark/validator/PPLQueryValidator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public static OpenSearchPPLParser getPplParser(String pplQuery) {
4545
new OpenSearchPPLParser(
4646
new CommonTokenStream(new OpenSearchPPLLexer(new CaseInsensitiveCharStream(pplQuery))));
4747
sqlBaseParser.addErrorListener(new SyntaxAnalysisErrorListener());
48-
// TODO add SPL compatible grammar supporting in Async Q?
4948
return sqlBaseParser;
5049
}
5150
}

common/src/main/java/org/opensearch/sql/common/setting/Settings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public enum Key {
2929
PATTERN_MODE("plugins.ppl.pattern.mode"),
3030
PATTERN_MAX_SAMPLE_COUNT("plugins.ppl.pattern.max.sample.count"),
3131
PATTERN_BUFFER_LIMIT("plugins.ppl.pattern.buffer.limit"),
32-
SPL_COMPATIBLE_GRAMMAR_ENABLED("plugins.ppl.spl_compatible.enabled"),
3332

3433
/** Enable Calcite as execution engine */
3534
CALCITE_ENGINE_ENABLED("plugins.calcite.enabled"),

core/src/main/java/org/opensearch/sql/calcite/CalcitePlanContext.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class CalcitePlanContext {
3535
public final FunctionProperties functionProperties;
3636
public final QueryType queryType;
3737
public final Integer querySizeLimit;
38-
public final boolean splCompatible;
3938

4039
@Getter @Setter private boolean isResolvingJoinCondition = false;
4140
@Getter @Setter private boolean isResolvingSubquery = false;
@@ -53,8 +52,7 @@ public class CalcitePlanContext {
5352

5453
@Getter public Map<String, RexLambdaRef> rexLambdaRefMap;
5554

56-
private CalcitePlanContext(
57-
FrameworkConfig config, Integer querySizeLimit, QueryType queryType, boolean splCompatible) {
55+
private CalcitePlanContext(FrameworkConfig config, Integer querySizeLimit, QueryType queryType) {
5856
this.config = config;
5957
this.querySizeLimit = querySizeLimit;
6058
this.queryType = queryType;
@@ -63,7 +61,6 @@ private CalcitePlanContext(
6361
this.rexBuilder = new ExtendedRexBuilder(relBuilder.getRexBuilder());
6462
this.functionProperties = new FunctionProperties(QueryType.PPL);
6563
this.rexLambdaRefMap = new HashMap<>();
66-
this.splCompatible = splCompatible;
6764
}
6865

6966
public RexNode resolveJoinCondition(
@@ -96,12 +93,12 @@ public Optional<RexCorrelVariable> peekCorrelVar() {
9693
}
9794

9895
public CalcitePlanContext clone() {
99-
return new CalcitePlanContext(config, querySizeLimit, queryType, splCompatible);
96+
return new CalcitePlanContext(config, querySizeLimit, queryType);
10097
}
10198

10299
public static CalcitePlanContext create(
103-
FrameworkConfig config, Integer querySizeLimit, QueryType queryType, boolean splCompatible) {
104-
return new CalcitePlanContext(config, querySizeLimit, queryType, splCompatible);
100+
FrameworkConfig config, Integer querySizeLimit, QueryType queryType) {
101+
return new CalcitePlanContext(config, querySizeLimit, queryType);
105102
}
106103

107104
public void putRexLambdaRefMap(Map<String, RexLambdaRef> candidateMap) {

core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ private Optional<RexLiteral> extractAliasLiteral(RexNode node) {
676676
public RelNode visitJoin(Join node, CalcitePlanContext context) {
677677
List<UnresolvedPlan> children = node.getChildren();
678678
children.forEach(c -> analyze(c, context));
679-
if (context.splCompatible && node.getJoinCondition().isEmpty()) {
679+
if (node.getJoinCondition().isEmpty()) {
680680
// For spl compatible grammar
681681
List<String> leftColumns = context.relBuilder.peek(1).getRowType().getFieldNames();
682682
List<String> rightColumns = context.relBuilder.peek().getRowType().getFieldNames();
@@ -722,9 +722,7 @@ public RelNode visitJoin(Join node, CalcitePlanContext context) {
722722
}
723723
return context.relBuilder.peek();
724724
}
725-
// For PPL native grammar
726-
// not allowed: node.getJoinCondition().isEmpty() = true && context.splCompatible = false
727-
// here is: node.getJoinCondition().isEmpty() = false
725+
// The join old grammar doesn't allow empty join condition
728726
RexNode joinCondition =
729727
node.getJoinCondition()
730728
.map(c -> rexVisitor.analyzeJoinCondition(c, context))

core/src/main/java/org/opensearch/sql/executor/QueryService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void explainWithCalcite(
133133
() -> {
134134
CalcitePlanContext context =
135135
CalcitePlanContext.create(
136-
buildFrameworkConfig(), getQuerySizeLimit(), queryType, isSplCompatible());
136+
buildFrameworkConfig(), getQuerySizeLimit(), queryType);
137137
RelNode relNode = analyze(plan, context);
138138
RelNode optimized = optimize(relNode, context);
139139
RelNode calcitePlan = convertToCalcitePlan(optimized);
@@ -281,10 +281,6 @@ private Integer getQuerySizeLimit() {
281281
return settings == null ? null : settings.getSettingValue(Key.QUERY_SIZE_LIMIT);
282282
}
283283

284-
private boolean isSplCompatible() {
285-
return settings == null ? false : settings.getSettingValue(Key.SPL_COMPATIBLE_GRAMMAR_ENABLED);
286-
}
287-
288284
// TODO https://github.com/opensearch-project/sql/issues/3457
289285
// Calcite is not available for SQL query now. Maybe release in 3.1.0?
290286
private boolean shouldUseCalcite(QueryType queryType) {

core/src/test/java/org/opensearch/sql/calcite/CalciteRexNodeVisitorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void setUpContext() {
6666

6767
mockedStatic.when(() -> CalciteToolsHelper.create(any(), any(), any())).thenReturn(relBuilder);
6868

69-
context = CalcitePlanContext.create(frameworkConfig, 100, QueryType.PPL, true);
69+
context = CalcitePlanContext.create(frameworkConfig, 100, QueryType.PPL);
7070
}
7171

7272
@AfterEach

docs/user/admin/settings.rst

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -792,16 +792,4 @@ If Calcite pushdown optimization is enabled, this setting is used to estimate th
792792

793793
1. The default value is 0.9 since 3.1.0.
794794
2. This setting is node scope.
795-
3. This setting can be updated dynamically.
796-
797-
plugins.ppl.spl_compatible.enabled
798-
==================================
799-
800-
Description
801-
-----------
802-
803-
This setting is present from 3.2.0. Enabling Calcite is a prerequisite. You can use this setting to decide whether to allow parsing a query of Splunk SPL compatible grammar.
804-
805-
1. The default value is false.
806-
2. This setting is node scope.
807-
3. This setting can be updated dynamically.
795+
3. This setting can be updated dynamically.

docs/user/ppl/admin/settings.rst

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -89,38 +89,6 @@ PPL query::
8989
"transient": {}
9090
}
9191

92-
plugins.ppl.spl_compatible.enabled
93-
==================================
94-
95-
Description
96-
-----------
97-
98-
This setting is present from 3.2.0. Enabling Calcite is a prerequisite. You can use this setting to decide whether to allow parsing a query of Splunk SPL compatible grammar.
99-
100-
1. The default value is false.
101-
2. This setting is node scope.
102-
3. This setting can be updated dynamically.
103-
104-
Example
105-
-------
106-
107-
PPL query::
108-
109-
sh$ curl -sS -H 'Content-Type: application/json' \
110-
... -X PUT localhost:9200/_plugins/_query/settings \
111-
... -d '{"persistent" : {"plugins.ppl.spl_compatible.enabled" : "true"}}'
112-
{
113-
"acknowledged": true,
114-
"persistent": {
115-
"plugins": {
116-
"spl_compatible": {
117-
"enabled": "true"
118-
}
119-
}
120-
},
121-
"transient": {}
122-
}
123-
12492
plugins.query.memory_limit
12593
==========================
12694

docs/user/ppl/cmd/join.rst

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,35 @@ join
1111

1212
Description
1313
===========
14-
| (Experimental)
15-
| (Since 3.0.0)
1614
| Using ``join`` command to combines two datasets together. The left side could be an index or results from a piped commands, the right side could be either an index or a subsearch.
1715
1816
Version
1917
=======
2018
3.0.0
2119

22-
Syntax
23-
======
24-
[joinType] join [leftAlias] [rightAlias] on <joinCriteria> <right-dataset>
20+
Syntax-1
21+
========
22+
| [joinType] join [leftAlias] [rightAlias] on <joinCriteria> <right-dataset>
2523
2624
* joinType: optional. The type of join to perform. The default is ``INNER`` if not specified. Other option is ``LEFT [OUTER]``, ``RIGHT [OUTER]``, ``FULL [OUTER]``, ``CROSS``, ``[LEFT] SEMI``, ``[LEFT] ANTI``.
2725
* leftAlias: optional. The subsearch alias to use with the left join side, to avoid ambiguous naming. Fixed pattern: ``left = <leftAlias>``
2826
* rightAlias: optional. The subsearch alias to use with the right join side, to avoid ambiguous naming. Fixed pattern: ``right = <rightAlias>``
2927
* joinCriteria: mandatory. It could be any comparison expression.
30-
* right-dataset: mandatory. Right dataset could be either an index or a subsearch with/without alias.
28+
* right-dataset: mandatory. Right dataset could be either an ``index`` or a ``subsearch`` with/without alias.
3129

32-
SPL Compatible Syntax
33-
=====================
34-
| (Experimental)
35-
| (Since 3.2.0)
36-
| (prerequisite: plugins.ppl.spl_compatible.enabled=true)
30+
Syntax-2
31+
========
32+
| (Since 3.3.0)
3733
| join [type=<joinType>] [overwrite=<bool>] <join-field-list> <right-dataset>
3834
3935
* type=<joinType>: optional. The type of join to perform. The default is ``INNER`` if not specified. Other option is ``LEFT``, ``RIGHT``, ``FULL``, ``CROSS``, ``SEMI``, ``ANTI``.
4036
* overwrite=<bool>: optional. Specifies whether duplicate-named fields from <right-dataset> (subsearch results) should replace corresponding fields in the main search results. The default value is ``true``.
4137
* join-field-list: optional. The fields to use to build join criteria. The ``join-field-list`` must be present in both sides. If no <join-field-list> is present, all fields that are common to both sides are used.
42-
* right-dataset: mandatory. Right dataset could be either an index or a subsearch with/without alias.
38+
* right-dataset: mandatory. Right dataset could be either an ``index`` or a ``subsearch`` with/without alias.
4339

4440
Configuration
4541
=============
46-
This command requires Calcite enabled. In 3.0.0-beta, as an experimental the Calcite configuration is disabled by default.
42+
This command requires Calcite enabled. In 3.0.0, as an experimental the Calcite configuration is disabled by default.
4743

4844
Enable Calcite::
4945

@@ -70,7 +66,7 @@ Result set::
7066
Usage
7167
=====
7268

73-
Join::
69+
Join (syntax-1)::
7470

7571
source = table1 | inner join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c
7672
source = table1 | left join left = l right = r on l.a = r.a table2 | fields l.a, r.a, b, c
@@ -85,6 +81,9 @@ Join::
8581
source = table1 as t1 | join left = l right = r on l.a = r.a table2 as t2 | fields l.a, r.a
8682
source = table1 as t1 | join left = l right = r on l.a = r.a table2 as t2 | fields t1.a, t2.a
8783
source = table1 | join left = l right = r on l.a = r.a [ source = table2 ] as s | fields l.a, s.a
84+
85+
Join (syntax-2)::
86+
8887
source = table1 | join a table2 | fields a, b, c
8988
source = table1 | join a, b table2 | fields a, b, c
9089
source = table1 | join type=left overwrite=false a, b [source=table2 | rename d as b] | fields a, b, c
@@ -158,7 +157,7 @@ PPL query::
158157

159158
Limitation
160159
==========
161-
If fields in the left outputs and right outputs have the same name. Typically, in the join criteria
160+
In syntax-1, if fields in the left outputs and right outputs have the same name. Typically, in the join criteria
162161
``ON t1.id = t2.id``, the names ``id`` in output are ambiguous. To avoid ambiguous, the ambiguous
163162
fields in output rename to ``<alias>.id``, or else ``<tableName>.id`` if no alias existing.
164163

@@ -179,4 +178,4 @@ Assume table1 and table2 only contain field ``id``, following PPL queries and th
179178
* - source=table1 | join right=tt on table1.id=t2.id [ source=table2 as t2 | eval b = id ] | eval a = 1
180179
- table1.id, tt.id, tt.b, a
181180

182-
For the Splunk SPL compatible syntax (since 3.2.0), duplicate-named fields in output results are deduplicated, with field retention determined by the value of 'overwrite' option.
181+
But for the syntax-2 (since 3.2.0), duplicate-named fields in output results are deduplicated, with field retention determined by the value of 'overwrite' option.

0 commit comments

Comments
 (0)