Skip to content

Commit 8729c32

Browse files
committed
Merge branch 'main' into 2.x
2 parents dabe1d7 + ce15448 commit 8729c32

File tree

104 files changed

+4593
-854
lines changed

Some content is hidden

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

104 files changed

+4593
-854
lines changed

.github/workflows/draft-release-notes-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ jobs:
1616
with:
1717
config-name: draft-release-notes-config.yml
1818
tag: (None)
19-
version: 2.1.0.0
19+
version: 2.2.0.0
2020
env:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/sql-odbc-release-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
ODBC_BUILD_PATH: "./build/odbc/build"
1313
AWS_SDK_INSTALL_PATH: "./build/aws-sdk/install"
1414
PLUGIN_NAME: opensearch-sql-odbc
15-
OD_VERSION: 2.1.0.0
15+
OD_VERSION: 2.2.0.0
1616

1717
jobs:
1818
build-mac:

.github/workflows/sql-workbench-release-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
env:
99
PLUGIN_NAME: query-workbench-dashboards
1010
OPENSEARCH_VERSION: 'main'
11-
OPENSEARCH_PLUGIN_VERSION: 2.1.0.0
11+
OPENSEARCH_PLUGIN_VERSION: 2.2.0.0
1212

1313
jobs:
1414

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [pull_request, push]
55
env:
66
PLUGIN_NAME: query-workbench-dashboards
77
OPENSEARCH_VERSION: 'main'
8-
OPENSEARCH_PLUGIN_VERSION: 2.1.0.0
8+
OPENSEARCH_PLUGIN_VERSION: 2.2.0.0
99

1010
jobs:
1111

@@ -22,45 +22,45 @@ jobs:
2222
with:
2323
repository: opensearch-project/Opensearch-Dashboards
2424
ref: ${{ env.OPENSEARCH_VERSION }}
25-
path: sql/OpenSearch-Dashboards
25+
path: OpenSearch-Dashboards
2626

2727
- name: Setup Node
2828
uses: actions/setup-node@v2
2929
with:
30-
node-version-file: "./OpenSearch-Dashboards/.nvmrc"
30+
node-version-file: "../OpenSearch-Dashboards/.nvmrc"
3131
registry-url: 'https://registry.npmjs.org'
3232

3333
- name: Move Workbench to Plugins Dir
3434
run: |
35-
mv workbench OpenSearch-Dashboards/plugins
35+
mv workbench ../OpenSearch-Dashboards/plugins
3636
3737
- name: OpenSearch Dashboards Plugin Bootstrap
3838
uses: nick-invision/retry@v1
3939
with:
4040
timeout_minutes: 60
4141
max_attempts: 3
42-
command: cd OpenSearch-Dashboards/plugins/workbench; yarn osd bootstrap
42+
command: cd ../OpenSearch-Dashboards/plugins/workbench; yarn osd bootstrap
4343

4444
- name: Test
4545
run: |
46-
cd OpenSearch-Dashboards/plugins/workbench
46+
cd ../OpenSearch-Dashboards/plugins/workbench
4747
yarn test:jest --coverage
4848
4949
- name: Upload coverage
5050
uses: codecov/codecov-action@v1
5151
with:
5252
flags: query-workbench
53-
directory: ./OpenSearch-Dashboards/plugins/workbench
53+
directory: ../OpenSearch-Dashboards/plugins/workbench
5454
token: ${{ secrets.CODECOV_TOKEN }}
5555

5656
- name: Build Artifact
5757
run: |
58-
cd OpenSearch-Dashboards/plugins/workbench
58+
cd ../OpenSearch-Dashboards/plugins/workbench
5959
yarn build
6060
mv ./build/*.zip ./build/${{ env.PLUGIN_NAME }}-${{ env.OPENSEARCH_PLUGIN_VERSION }}.zip
6161
6262
- name: Upload Artifact
6363
uses: actions/upload-artifact@v1
6464
with:
6565
name: workbench
66-
path: OpenSearch-Dashboards/plugins/workbench/build
66+
path: ../OpenSearch-Dashboards/plugins/workbench/build

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@
66

77
buildscript {
88
ext {
9+
<<<<<<< HEAD
910
opensearch_version = System.getProperty("opensearch.version", "2.1.0-SNAPSHOT")
1011
spring_version = "5.3.22"
1112
jackson_version = "2.13.3"
1213
jackson_databind_version = "2.13.3"
14+
=======
15+
opensearch_version = System.getProperty("opensearch.version", "2.2.0-SNAPSHOT")
16+
spring_version = "5.3.22"
17+
jackson_version = "2.13.3"
18+
>>>>>>> main
1319
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
1420
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
1521
version_tokens = opensearch_version.tokenize('-')

common/src/main/java/org/opensearch/sql/common/utils/StringUtils.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,54 @@ public static String unquote(String text, String mark) {
2727

2828
/**
2929
* Unquote Identifier which has " or ' or ` as mark.
30+
* Strings quoted by ' or " with two of these quotes appearing next to each other in the quote
31+
* acts as an escape
32+
* Example: 'Test''s' will result in 'Test's', similar with those single quotes being replaced
33+
* with double.
3034
* @param text string
3135
* @return An unquoted string whose outer pair of (single/double/back-tick) quotes have been
3236
* removed
3337
*/
3438
public static String unquoteText(String text) {
35-
if (isQuoted(text, "\"") || isQuoted(text, "'") || isQuoted(text, "`")) {
36-
return text.substring(1, text.length() - 1);
39+
40+
if (text.length() < 2) {
41+
return text;
42+
}
43+
44+
char enclosingQuote;
45+
char firstChar = text.charAt(0);
46+
char lastChar = text.charAt(text.length() - 1);
47+
48+
if (firstChar == lastChar
49+
&& (firstChar == '\''
50+
|| firstChar == '"'
51+
|| firstChar == '`')) {
52+
enclosingQuote = firstChar;
3753
} else {
3854
return text;
3955
}
56+
57+
if (enclosingQuote == '`') {
58+
return text.substring(1, text.length() - 1);
59+
}
60+
61+
char currentChar;
62+
char nextChar;
63+
64+
StringBuilder textSB = new StringBuilder();
65+
66+
// Ignores first and last character as they are the quotes that should be removed
67+
for (int chIndex = 1; chIndex < text.length() - 1; chIndex++) {
68+
currentChar = text.charAt(chIndex);
69+
nextChar = text.charAt(chIndex + 1);
70+
if (currentChar == enclosingQuote
71+
&& nextChar == currentChar) {
72+
chIndex++;
73+
}
74+
textSB.append(currentChar);
75+
}
76+
77+
return textSB.toString();
4078
}
4179

4280
/**

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@ public LogicalPlan visitProject(Project node, AnalysisContext context) {
292292
child = windowAnalyzer.analyze(expr, context);
293293
}
294294

295+
for (UnresolvedExpression expr : node.getProjectList()) {
296+
HighlightAnalyzer highlightAnalyzer = new HighlightAnalyzer(expressionAnalyzer, child);
297+
child = highlightAnalyzer.analyze(expr, context);
298+
299+
}
300+
295301
List<NamedExpression> namedExpressions =
296302
selectExpressionAnalyzer.analyze(node.getProjectList(), context,
297303
new ExpressionReferenceOptimizer(expressionAnalyzer.getRepository(), child));

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
import java.util.ArrayList;
1212
import java.util.Arrays;
1313
import java.util.Collections;
14-
import java.util.LinkedHashMap;
1514
import java.util.List;
16-
import java.util.Map;
1715
import java.util.Optional;
1816
import java.util.stream.Collectors;
1917
import lombok.Getter;
@@ -29,6 +27,7 @@
2927
import org.opensearch.sql.ast.expression.EqualTo;
3028
import org.opensearch.sql.ast.expression.Field;
3129
import org.opensearch.sql.ast.expression.Function;
30+
import org.opensearch.sql.ast.expression.HighlightFunction;
3231
import org.opensearch.sql.ast.expression.In;
3332
import org.opensearch.sql.ast.expression.Interval;
3433
import org.opensearch.sql.ast.expression.Literal;
@@ -44,12 +43,12 @@
4443
import org.opensearch.sql.ast.expression.WindowFunction;
4544
import org.opensearch.sql.ast.expression.Xor;
4645
import org.opensearch.sql.common.antlr.SyntaxCheckException;
47-
import org.opensearch.sql.data.model.ExprTupleValue;
4846
import org.opensearch.sql.data.model.ExprValueUtils;
4947
import org.opensearch.sql.data.type.ExprType;
5048
import org.opensearch.sql.exception.SemanticCheckException;
5149
import org.opensearch.sql.expression.DSL;
5250
import org.opensearch.sql.expression.Expression;
51+
import org.opensearch.sql.expression.HighlightExpression;
5352
import org.opensearch.sql.expression.LiteralExpression;
5453
import org.opensearch.sql.expression.NamedArgumentExpression;
5554
import org.opensearch.sql.expression.NamedExpression;
@@ -191,6 +190,12 @@ public Expression visitWindowFunction(WindowFunction node, AnalysisContext conte
191190
return expr;
192191
}
193192

193+
@Override
194+
public Expression visitHighlight(HighlightFunction node, AnalysisContext context) {
195+
Expression expr = node.getHighlightField().accept(this, context);
196+
return new HighlightExpression(expr);
197+
}
198+
194199
@Override
195200
public Expression visitIn(In node, AnalysisContext context) {
196201
return visitIn(node.getField(), node.getValueList(), context);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.sql.analysis;
7+
8+
import lombok.RequiredArgsConstructor;
9+
import org.opensearch.sql.ast.AbstractNodeVisitor;
10+
import org.opensearch.sql.ast.expression.Alias;
11+
import org.opensearch.sql.ast.expression.HighlightFunction;
12+
import org.opensearch.sql.ast.expression.UnresolvedExpression;
13+
import org.opensearch.sql.expression.Expression;
14+
import org.opensearch.sql.planner.logical.LogicalHighlight;
15+
import org.opensearch.sql.planner.logical.LogicalPlan;
16+
17+
/**
18+
* Analyze the highlight in the {@link AnalysisContext} to construct the {@link
19+
* LogicalPlan}.
20+
*/
21+
@RequiredArgsConstructor
22+
public class HighlightAnalyzer extends AbstractNodeVisitor<LogicalPlan, AnalysisContext> {
23+
private final ExpressionAnalyzer expressionAnalyzer;
24+
private final LogicalPlan child;
25+
26+
public LogicalPlan analyze(UnresolvedExpression projectItem, AnalysisContext context) {
27+
LogicalPlan highlight = projectItem.accept(this, context);
28+
return (highlight == null) ? child : highlight;
29+
}
30+
31+
@Override
32+
public LogicalPlan visitAlias(Alias node, AnalysisContext context) {
33+
if (!(node.getDelegated() instanceof HighlightFunction)) {
34+
return null;
35+
}
36+
37+
HighlightFunction unresolved = (HighlightFunction) node.getDelegated();
38+
Expression field = expressionAnalyzer.analyze(unresolved.getHighlightField(), context);
39+
return new LogicalHighlight(child, field);
40+
}
41+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.opensearch.sql.ast.expression.EqualTo;
1919
import org.opensearch.sql.ast.expression.Field;
2020
import org.opensearch.sql.ast.expression.Function;
21+
import org.opensearch.sql.ast.expression.HighlightFunction;
2122
import org.opensearch.sql.ast.expression.In;
2223
import org.opensearch.sql.ast.expression.Interval;
2324
import org.opensearch.sql.ast.expression.Let;
@@ -254,4 +255,8 @@ public T visitKmeans(Kmeans node, C context) {
254255
public T visitAD(AD node, C context) {
255256
return visitChildren(node, context);
256257
}
258+
259+
public T visitHighlight(HighlightFunction node, C context) {
260+
return visitChildren(node, context);
261+
}
257262
}

core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.opensearch.sql.ast.expression.EqualTo;
2323
import org.opensearch.sql.ast.expression.Field;
2424
import org.opensearch.sql.ast.expression.Function;
25+
import org.opensearch.sql.ast.expression.HighlightFunction;
2526
import org.opensearch.sql.ast.expression.In;
2627
import org.opensearch.sql.ast.expression.Interval;
2728
import org.opensearch.sql.ast.expression.Let;
@@ -261,6 +262,10 @@ public When when(UnresolvedExpression condition, UnresolvedExpression result) {
261262
return new When(condition, result);
262263
}
263264

265+
public UnresolvedExpression highlight(UnresolvedExpression fieldName) {
266+
return new HighlightFunction(fieldName);
267+
}
268+
264269
public UnresolvedExpression window(UnresolvedExpression function,
265270
List<UnresolvedExpression> partitionByList,
266271
List<Pair<SortOption, UnresolvedExpression>> sortList) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.sql.ast.expression;
7+
8+
import java.util.List;
9+
import lombok.AllArgsConstructor;
10+
import lombok.EqualsAndHashCode;
11+
import lombok.Getter;
12+
import lombok.ToString;
13+
import org.opensearch.sql.ast.AbstractNodeVisitor;
14+
15+
/**
16+
* Expression node of Highlight function.
17+
*/
18+
@AllArgsConstructor
19+
@EqualsAndHashCode(callSuper = false)
20+
@Getter
21+
@ToString
22+
public class HighlightFunction extends UnresolvedExpression {
23+
private final UnresolvedExpression highlightField;
24+
25+
@Override
26+
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
27+
return nodeVisitor.visitHighlight(this, context);
28+
}
29+
30+
@Override
31+
public List<UnresolvedExpression> getChild() {
32+
return List.of(highlightField);
33+
}
34+
}

core/src/main/java/org/opensearch/sql/expression/ExpressionNodeVisitor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public T visitNamed(NamedExpression node, C context) {
5555
return node.getDelegated().accept(this, context);
5656
}
5757

58+
public T visitHighlight(HighlightExpression node, C context) {
59+
return visitNode(node, context);
60+
}
61+
5862
public T visitReference(ReferenceExpression node, C context) {
5963
return visitNode(node, context);
6064
}

0 commit comments

Comments
 (0)