Skip to content

Commit 7bb52a8

Browse files
authored
Merge pull request #830 from penghuo/backport/2.x
Merge main to 2.x
2 parents 581e3c8 + 7fb91c7 commit 7bb52a8

File tree

128 files changed

+2032
-1119
lines changed

Some content is hidden

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

128 files changed

+2032
-1119
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.2.0.0
19+
version: 2.3.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.2.0.0
15+
OD_VERSION: 2.3.0.0
1616

1717
jobs:
1818
build-mac:

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
- name: Build with Gradle
2323
run: ./gradlew build assemble
2424

25+
- name: Run backward compatibility tests
26+
run: ./scripts/bwctest.sh
27+
2528
- name: Create Artifact Path
2629
run: |
2730
mkdir -p opensearch-sql-builds

.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.2.0.0
11+
OPENSEARCH_PLUGIN_VERSION: 2.3.0.0
1212

1313
jobs:
1414

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

Lines changed: 1 addition & 1 deletion
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.2.0.0
8+
OPENSEARCH_PLUGIN_VERSION: 2.3.0.0
99

1010
jobs:
1111

MAINTAINERS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
| Chen Dai | [dai-chen](https://github.com/dai-chen) | Amazon |
1010
| Chloe Zhang | [chloe-zh](https://github.com/chloe-zh) | Amazon |
1111
| Nick Knize | [nknize](https://github.com/nknize) | Amazon |
12-
| Charlotte Henkle | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
12+
| Charlotte Henkle | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
13+
| Max Ksyunz | [MaxKsyunz](https://github.com/MaxKsyunz) | BitQuill |
14+
| Yury Fridlyand | [Yury-Fridlyand](https://github.com/Yury-Fridlyand) | BitQuill |

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [Code Summary](#code-summary)
55
- [Highlights](#highlights)
66
- [Documentation](#documentation)
7+
- [OpenSearch Forum](#forum)
78
- [Contributing](#contributing)
89
- [Attribution](#attribution)
910
- [Code of Conduct](#code-of-conduct)
@@ -127,6 +128,10 @@ Recently we have been actively improving our query engine primarily for better c
127128

128129
Please refer to the [SQL Language Reference Manual](./docs/user/index.rst), [Piped Processing Language (PPL) Reference Manual](./docs/user/ppl/index.rst) and [Technical Documentation](https://opensearch.org/docs/latest/search-plugins/sql/index/) for detailed information on installing and configuring plugin.
129130

131+
## Forum
132+
133+
For additional help with the plugin, including questions about opening an issue, visit the OpenSearch [Forum](https://forum.opensearch.org/c/plugins/sql/8).
134+
130135
## Contributing
131136

132137
See [developer guide](DEVELOPER_GUIDE.rst) and [how to contribute to this project](CONTRIBUTING.md).

bi-connectors/PowerBIConnector/src/OpenSearchProject.query.pq

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ shared MyExtension.UnitTest =
77
Host = "localhost",
88
Port = 9200,
99
UseSSL = false,
10+
HostnameVerification = false,
1011

1112
facts =
1213
{
1314
Fact("Connection Test",
1415
7,
1516
let
16-
Source = OpenSearch.Contents(Host, Port, UseSSL),
17+
Source = OpenSearchProject.Contents(Host, Port, UseSSL, HostnameVerification),
1718
no_of_columns = Table.ColumnCount(Source)
1819
in
1920
no_of_columns
@@ -22,7 +23,7 @@ shared MyExtension.UnitTest =
2223
#table(type table [bool0 = logical],
2324
{ {null}, {false}, {true} }),
2425
let
25-
Source = OpenSearch.Contents(Host, Port, UseSSL),
26+
Source = OpenSearchProject.Contents(Host, Port, UseSSL, HostnameVerification),
2627
calcs_null_null = Source{[Item="calcs",Schema=null,Catalog=null]}[Data],
2728
grouped = Table.Group(calcs_null_null, {"bool0"}, {})
2829
in

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
buildscript {
88
ext {
9-
opensearch_version = System.getProperty("opensearch.version", "2.2.0-SNAPSHOT")
9+
opensearch_version = System.getProperty("opensearch.version", "2.3.0-SNAPSHOT")
1010
spring_version = "5.3.22"
1111
jackson_version = "2.13.3"
1212
isSnapshot = "true" == System.getProperty("build.snapshot", "true")

core/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ dependencies {
4545
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
4646
api group: 'com.facebook.presto', name: 'presto-matching', version: '0.240'
4747
api group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
48+
api "com.fasterxml.jackson.core:jackson-core:${jackson_version}"
49+
api "com.fasterxml.jackson.core:jackson-databind:${jackson_version}"
50+
api "com.fasterxml.jackson.core:jackson-annotations:${jackson_version}"
4851
api project(':common')
4952

5053
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
@@ -70,7 +73,7 @@ jacocoTestReport {
7073
afterEvaluate {
7174
classDirectories.setFrom(files(classDirectories.files.collect {
7275
fileTree(dir: it,
73-
exclude: ['**/ast/**'])
76+
exclude: ['**/ast/**', '**/catalog/model/**'])
7477
}))
7578
}
7679
}
@@ -80,7 +83,9 @@ jacocoTestCoverageVerification {
8083
rule {
8184
element = 'CLASS'
8285
excludes = [
83-
'org.opensearch.sql.utils.MLCommonsConstants'
86+
'org.opensearch.sql.utils.MLCommonsConstants',
87+
'org.opensearch.sql.utils.Constants',
88+
'org.opensearch.sql.catalog.model.*'
8489
]
8590
limit {
8691
counter = 'LINE'

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.opensearch.sql.ast.tree.Sort.SortOption;
5656
import org.opensearch.sql.ast.tree.UnresolvedPlan;
5757
import org.opensearch.sql.ast.tree.Values;
58+
import org.opensearch.sql.catalog.CatalogService;
5859
import org.opensearch.sql.data.model.ExprMissingValue;
5960
import org.opensearch.sql.data.type.ExprCoreType;
6061
import org.opensearch.sql.exception.SemanticCheckException;
@@ -81,7 +82,6 @@
8182
import org.opensearch.sql.planner.logical.LogicalRename;
8283
import org.opensearch.sql.planner.logical.LogicalSort;
8384
import org.opensearch.sql.planner.logical.LogicalValues;
84-
import org.opensearch.sql.storage.StorageEngine;
8585
import org.opensearch.sql.storage.Table;
8686
import org.opensearch.sql.utils.ParseUtils;
8787

@@ -97,16 +97,16 @@ public class Analyzer extends AbstractNodeVisitor<LogicalPlan, AnalysisContext>
9797

9898
private final NamedExpressionAnalyzer namedExpressionAnalyzer;
9999

100-
private final StorageEngine storageEngine;
100+
private final CatalogService catalogService;
101101

102102
/**
103103
* Constructor.
104104
*/
105105
public Analyzer(
106106
ExpressionAnalyzer expressionAnalyzer,
107-
StorageEngine storageEngine) {
107+
CatalogService catalogService) {
108108
this.expressionAnalyzer = expressionAnalyzer;
109-
this.storageEngine = storageEngine;
109+
this.catalogService = catalogService;
110110
this.selectExpressionAnalyzer = new SelectExpressionAnalyzer(expressionAnalyzer);
111111
this.namedExpressionAnalyzer = new NamedExpressionAnalyzer(expressionAnalyzer);
112112
}
@@ -119,16 +119,33 @@ public LogicalPlan analyze(UnresolvedPlan unresolved, AnalysisContext context) {
119119
public LogicalPlan visitRelation(Relation node, AnalysisContext context) {
120120
context.push();
121121
TypeEnvironment curEnv = context.peek();
122-
Table table = storageEngine.getTable(node.getTableName());
122+
String catalogName = getCatalogName(node);
123+
String tableName = getTableName(node);
124+
if (catalogName != null && !catalogService.getCatalogs().contains(catalogName)) {
125+
tableName = catalogName + "." + tableName;
126+
catalogName = null;
127+
}
128+
Table table = catalogService
129+
.getStorageEngine(catalogName)
130+
.getTable(tableName);
123131
table.getFieldTypes().forEach((k, v) -> curEnv.define(new Symbol(Namespace.FIELD_NAME, k), v));
124132

125133
// Put index name or its alias in index namespace on type environment so qualifier
126134
// can be removed when analyzing qualified name. The value (expr type) here doesn't matter.
127135
curEnv.define(new Symbol(Namespace.INDEX_NAME, node.getTableNameOrAlias()), STRUCT);
128136

129-
return new LogicalRelation(node.getTableName());
137+
return new LogicalRelation(tableName, table);
138+
}
139+
140+
private String getTableName(Relation node) {
141+
return node.getTableName();
130142
}
131143

144+
private String getCatalogName(Relation node) {
145+
return node.getCatalogName();
146+
}
147+
148+
132149
@Override
133150
public LogicalPlan visitRelationSubquery(RelationSubquery node, AnalysisContext context) {
134151
LogicalPlan subquery = analyze(node.getChild().get(0), context);

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package org.opensearch.sql.ast.dsl;
88

99
import java.util.Arrays;
10+
import java.util.Collections;
1011
import java.util.List;
1112
import lombok.experimental.UtilityClass;
1213
import org.apache.commons.lang3.tuple.Pair;
@@ -71,6 +72,10 @@ public UnresolvedPlan relation(String tableName) {
7172
return new Relation(qualifiedName(tableName));
7273
}
7374

75+
public UnresolvedPlan relation(QualifiedName tableName) {
76+
return new Relation(tableName);
77+
}
78+
7479
public UnresolvedPlan relation(String tableName, String alias) {
7580
return new Relation(qualifiedName(tableName), alias);
7681
}
@@ -114,7 +119,7 @@ public static UnresolvedPlan rename(UnresolvedPlan input, Map... maps) {
114119
/**
115120
* Initialize Values node by rows of literals.
116121
* @param values rows in which each row is a list of literal values
117-
* @return Values node
122+
* @return Values node
118123
*/
119124
@SafeVarargs
120125
public UnresolvedPlan values(List<Literal>... values) {
@@ -413,7 +418,8 @@ public static List<Argument> defaultTopArgs() {
413418
}
414419

415420
public static RareTopN rareTopN(UnresolvedPlan input, CommandType commandType,
416-
List<Argument> noOfResults, List<UnresolvedExpression> groupList, Field... fields) {
421+
List<Argument> noOfResults, List<UnresolvedExpression> groupList,
422+
Field... fields) {
417423
return new RareTopN(input, commandType, noOfResults, Arrays.asList(fields), groupList)
418424
.attach(input);
419425
}

core/src/main/java/org/opensearch/sql/ast/tree/Relation.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import lombok.RequiredArgsConstructor;
1616
import lombok.ToString;
1717
import org.opensearch.sql.ast.AbstractNodeVisitor;
18+
import org.opensearch.sql.ast.expression.QualifiedName;
1819
import org.opensearch.sql.ast.expression.UnresolvedExpression;
1920

2021
/**
@@ -46,17 +47,49 @@ public Relation(UnresolvedExpression tableName, String alias) {
4647
/**
4748
* Get original table name. Unwrap and get name if table name expression
4849
* is actually an Alias.
49-
* @return table name
50+
* In case of federated queries we are assuming single table.
51+
*
52+
* @return table name
5053
*/
5154
public String getTableName() {
55+
if (tableName.size() == 1 && ((QualifiedName) tableName.get(0)).first().isPresent()) {
56+
return ((QualifiedName) tableName.get(0)).rest().toString();
57+
}
58+
return tableName.stream()
59+
.map(UnresolvedExpression::toString)
60+
.collect(Collectors.joining(COMMA));
61+
}
62+
63+
/**
64+
* Get Catalog Name if present. Since in the initial phase we would be supporting single table
65+
* federation queries, we are making an assumption of one table.
66+
*
67+
* @return catalog name
68+
*/
69+
public String getCatalogName() {
70+
if (tableName.size() == 1) {
71+
if (tableName.get(0) instanceof QualifiedName) {
72+
return ((QualifiedName) tableName.get(0)).first().orElse(null);
73+
}
74+
}
75+
return null;
76+
}
77+
78+
/**
79+
* Return full qualified table name with catalog.
80+
*
81+
* @return fully qualified table name with catalog.
82+
*/
83+
public String getFullyQualifiedTableNameWithCatalog() {
5284
return tableName.stream()
5385
.map(UnresolvedExpression::toString)
5486
.collect(Collectors.joining(COMMA));
5587
}
5688

5789
/**
5890
* Get original table name or its alias if present in Alias.
59-
* @return table name or its alias
91+
*
92+
* @return table name or its alias
6093
*/
6194
public String getTableNameOrAlias() {
6295
return (alias == null) ? getTableName() : alias;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.sql.catalog;
7+
8+
import java.util.Set;
9+
import org.opensearch.sql.storage.StorageEngine;
10+
11+
/**
12+
* Catalog Service defines api for
13+
* providing and managing storage engines and execution engines
14+
* for all the catalogs.
15+
* The storage and execution indirectly make connections to the underlying datastore catalog.
16+
*/
17+
public interface CatalogService {
18+
19+
StorageEngine getStorageEngine(String catalog);
20+
21+
Set<String> getCatalogs();
22+
23+
void registerOpenSearchStorageEngine(StorageEngine storageEngine);
24+
25+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.sql.catalog.model;
7+
8+
import com.fasterxml.jackson.annotation.JsonFormat;
9+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
10+
import com.fasterxml.jackson.annotation.JsonSubTypes;
11+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
12+
import lombok.Getter;
13+
import lombok.Setter;
14+
15+
@JsonIgnoreProperties(ignoreUnknown = true)
16+
@JsonTypeInfo(
17+
use = JsonTypeInfo.Id.NAME,
18+
include = JsonTypeInfo.As.EXISTING_PROPERTY,
19+
property = "type",
20+
defaultImpl = AbstractAuthenticationData.class,
21+
visible = true)
22+
@JsonSubTypes({
23+
@JsonSubTypes.Type(value = BasicAuthenticationData.class, name = "basicauth"),
24+
})
25+
@Getter
26+
@Setter
27+
public abstract class AbstractAuthenticationData {
28+
29+
@JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
30+
private AuthenticationType type;
31+
32+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.sql.catalog.model;
7+
8+
public enum AuthenticationType {
9+
BASICAUTH,NO
10+
}

0 commit comments

Comments
 (0)