Skip to content

Commit fede123

Browse files
author
Guian Gumpac
committed
Fixed merge conflicts
Signed-off-by: Guian Gumpac <[email protected]>
2 parents b54a934 + 50669eb commit fede123

File tree

284 files changed

+8918
-4366
lines changed

Some content is hidden

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

284 files changed

+8918
-4366
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
matrix:
2626
entry:
2727
- { os: ubuntu-latest, java: 11 }
28-
- { os: windows-latest, java: 11, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc}
28+
- { os: windows-latest, java: 11, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc -PbuildPlatform=windows }
2929
- { os: macos-latest, java: 11, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc }
3030
- { os: ubuntu-latest, java: 17 }
31-
- { os: windows-latest, java: 17, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc }
31+
- { os: windows-latest, java: 17, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc -PbuildPlatform=windows }
3232
- { os: macos-latest, java: 17, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc }
3333
runs-on: ${{ matrix.entry.os }}
3434

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ gen
4444
/artifacts/
4545
/.pid.lock
4646
/.prom.pid.lock
47+
48+
.java-version

DEVELOPER_GUIDE.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ The plugin codebase is in standard layout of Gradle project::
141141
├── core
142142
├── doctest
143143
├── opensearch
144+
├── filesystem
145+
├── prometheus
144146
├── integ-test
145147
├── legacy
146148
├── plugin
@@ -159,6 +161,8 @@ Here are sub-folders (Gradle modules) for plugin source code:
159161
- ``ppl``: PPL language processor.
160162
- ``core``: core query engine.
161163
- ``opensearch``: OpenSearch storage engine.
164+
- ``prometheus``: Prometheus storage engine.
165+
- ``filesystem``: File System storage engine (in development).
162166
- ``protocol``: request/response protocol formatter.
163167
- ``common``: common util code.
164168
- ``integ-test``: integration and comparison test.

core/build.gradle

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,12 @@ plugins {
2626
id 'java-library'
2727
id "io.freefair.lombok"
2828
id 'jacoco'
29+
id 'java-test-fixtures'
2930
}
3031

3132
repositories {
3233
mavenCentral()
3334
}
34-
//
35-
//configurations.all {
36-
// resolutionStrategy.dependencySubstitution {
37-
// substitute module('com.google.guava:guava:26.0-jre') with module('com.google.guava:guava:29.0-jre')
38-
// }
39-
//}
4035

4136
dependencies {
4237
api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
@@ -73,7 +68,7 @@ jacocoTestReport {
7368
afterEvaluate {
7469
classDirectories.setFrom(files(classDirectories.files.collect {
7570
fileTree(dir: it,
76-
exclude: ['**/ast/**', '**/catalog/model/**'])
71+
exclude: ['**/ast/**', '**/datasource/model/**'])
7772
}))
7873
}
7974
}
@@ -85,7 +80,7 @@ jacocoTestCoverageVerification {
8580
excludes = [
8681
'org.opensearch.sql.utils.MLCommonsConstants',
8782
'org.opensearch.sql.utils.Constants',
88-
'org.opensearch.sql.catalog.model.*'
83+
'org.opensearch.sql.datasource.model.*'
8984
]
9085
limit {
9186
counter = 'LINE'

core/src/main/java/org/opensearch/sql/CatalogSchemaName.java renamed to core/src/main/java/org/opensearch/sql/DataSourceSchemaName.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
@Getter
1414
@RequiredArgsConstructor
15-
public class CatalogSchemaName {
15+
public class DataSourceSchemaName {
1616

17-
private final String catalogName;
17+
private final String dataSourceName;
1818

1919
private final String schemaName;
2020

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

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,11 @@
1111
import static org.opensearch.sql.ast.tree.Sort.SortOrder.ASC;
1212
import static org.opensearch.sql.ast.tree.Sort.SortOrder.DESC;
1313
import static org.opensearch.sql.data.type.ExprCoreType.STRUCT;
14-
import static org.opensearch.sql.utils.MLCommonsConstants.ACTION;
15-
import static org.opensearch.sql.utils.MLCommonsConstants.MODELID;
16-
import static org.opensearch.sql.utils.MLCommonsConstants.PREDICT;
1714
import static org.opensearch.sql.utils.MLCommonsConstants.RCF_ANOMALOUS;
1815
import static org.opensearch.sql.utils.MLCommonsConstants.RCF_ANOMALY_GRADE;
1916
import static org.opensearch.sql.utils.MLCommonsConstants.RCF_SCORE;
20-
import static org.opensearch.sql.utils.MLCommonsConstants.RCF_TIMESTAMP;
21-
import static org.opensearch.sql.utils.MLCommonsConstants.STATUS;
22-
import static org.opensearch.sql.utils.MLCommonsConstants.TASKID;
2317
import static org.opensearch.sql.utils.MLCommonsConstants.TIME_FIELD;
24-
import static org.opensearch.sql.utils.MLCommonsConstants.TRAIN;
25-
import static org.opensearch.sql.utils.MLCommonsConstants.TRAINANDPREDICT;
26-
import static org.opensearch.sql.utils.SystemIndexUtils.CATALOGS_TABLE_NAME;
18+
import static org.opensearch.sql.utils.SystemIndexUtils.DATASOURCES_TABLE_NAME;
2719

2820
import com.google.common.collect.ImmutableList;
2921
import com.google.common.collect.ImmutableList.Builder;
@@ -37,7 +29,7 @@
3729
import java.util.stream.Collectors;
3830
import org.apache.commons.lang3.tuple.ImmutablePair;
3931
import org.apache.commons.lang3.tuple.Pair;
40-
import org.opensearch.sql.CatalogSchemaName;
32+
import org.opensearch.sql.DataSourceSchemaName;
4133
import org.opensearch.sql.analysis.symbol.Namespace;
4234
import org.opensearch.sql.analysis.symbol.Symbol;
4335
import org.opensearch.sql.ast.AbstractNodeVisitor;
@@ -69,10 +61,10 @@
6961
import org.opensearch.sql.ast.tree.TableFunction;
7062
import org.opensearch.sql.ast.tree.UnresolvedPlan;
7163
import org.opensearch.sql.ast.tree.Values;
72-
import org.opensearch.sql.catalog.CatalogService;
73-
import org.opensearch.sql.catalog.model.Catalog;
7464
import org.opensearch.sql.data.model.ExprMissingValue;
7565
import org.opensearch.sql.data.type.ExprCoreType;
66+
import org.opensearch.sql.datasource.DataSourceService;
67+
import org.opensearch.sql.datasource.model.DataSource;
7668
import org.opensearch.sql.exception.SemanticCheckException;
7769
import org.opensearch.sql.expression.DSL;
7870
import org.opensearch.sql.expression.Expression;
@@ -101,7 +93,7 @@
10193
import org.opensearch.sql.planner.logical.LogicalRename;
10294
import org.opensearch.sql.planner.logical.LogicalSort;
10395
import org.opensearch.sql.planner.logical.LogicalValues;
104-
import org.opensearch.sql.planner.physical.catalog.CatalogTable;
96+
import org.opensearch.sql.planner.physical.datasource.DataSourceTable;
10597
import org.opensearch.sql.storage.Table;
10698
import org.opensearch.sql.utils.ParseUtils;
10799

@@ -117,7 +109,7 @@ public class Analyzer extends AbstractNodeVisitor<LogicalPlan, AnalysisContext>
117109

118110
private final NamedExpressionAnalyzer namedExpressionAnalyzer;
119111

120-
private final CatalogService catalogService;
112+
private final DataSourceService dataSourceService;
121113

122114
private final BuiltinFunctionRepository repository;
123115

@@ -126,10 +118,10 @@ public class Analyzer extends AbstractNodeVisitor<LogicalPlan, AnalysisContext>
126118
*/
127119
public Analyzer(
128120
ExpressionAnalyzer expressionAnalyzer,
129-
CatalogService catalogService,
121+
DataSourceService dataSourceService,
130122
BuiltinFunctionRepository repository) {
131123
this.expressionAnalyzer = expressionAnalyzer;
132-
this.catalogService = catalogService;
124+
this.dataSourceService = dataSourceService;
133125
this.selectExpressionAnalyzer = new SelectExpressionAnalyzer(expressionAnalyzer);
134126
this.namedExpressionAnalyzer = new NamedExpressionAnalyzer(expressionAnalyzer);
135127
this.repository = repository;
@@ -142,25 +134,27 @@ public LogicalPlan analyze(UnresolvedPlan unresolved, AnalysisContext context) {
142134
@Override
143135
public LogicalPlan visitRelation(Relation node, AnalysisContext context) {
144136
QualifiedName qualifiedName = node.getTableQualifiedName();
145-
Set<String> allowedCatalogNames = catalogService.getCatalogs()
137+
Set<String> allowedDataSourceNames = dataSourceService.getDataSources()
146138
.stream()
147-
.map(Catalog::getName)
139+
.map(DataSource::getName)
148140
.collect(Collectors.toSet());
149-
CatalogSchemaIdentifierNameResolver catalogSchemaIdentifierNameResolver
150-
= new CatalogSchemaIdentifierNameResolver(qualifiedName.getParts(), allowedCatalogNames);
151-
String tableName = catalogSchemaIdentifierNameResolver.getIdentifierName();
141+
DataSourceSchemaIdentifierNameResolver dataSourceSchemaIdentifierNameResolver
142+
= new DataSourceSchemaIdentifierNameResolver(qualifiedName.getParts(),
143+
allowedDataSourceNames);
144+
String tableName = dataSourceSchemaIdentifierNameResolver.getIdentifierName();
152145
context.push();
153146
TypeEnvironment curEnv = context.peek();
154147
Table table;
155-
if (CATALOGS_TABLE_NAME.equals(tableName)) {
156-
table = new CatalogTable(catalogService);
148+
if (DATASOURCES_TABLE_NAME.equals(tableName)) {
149+
table = new DataSourceTable(dataSourceService);
157150
} else {
158-
table = catalogService
159-
.getCatalog(catalogSchemaIdentifierNameResolver.getCatalogName())
151+
table = dataSourceService
152+
.getDataSource(dataSourceSchemaIdentifierNameResolver.getDataSourceName())
160153
.getStorageEngine()
161-
.getTable(new CatalogSchemaName(catalogSchemaIdentifierNameResolver.getCatalogName(),
162-
catalogSchemaIdentifierNameResolver.getSchemaName()),
163-
catalogSchemaIdentifierNameResolver.getIdentifierName());
154+
.getTable(new DataSourceSchemaName(
155+
dataSourceSchemaIdentifierNameResolver.getDataSourceName(),
156+
dataSourceSchemaIdentifierNameResolver.getSchemaName()),
157+
dataSourceSchemaIdentifierNameResolver.getIdentifierName());
164158
}
165159
table.getFieldTypes().forEach((k, v) -> curEnv.define(new Symbol(Namespace.FIELD_NAME, k), v));
166160

@@ -188,28 +182,29 @@ public LogicalPlan visitRelationSubquery(RelationSubquery node, AnalysisContext
188182
@Override
189183
public LogicalPlan visitTableFunction(TableFunction node, AnalysisContext context) {
190184
QualifiedName qualifiedName = node.getFunctionName();
191-
Set<String> allowedCatalogNames = catalogService.getCatalogs()
185+
Set<String> allowedDataSourceNames = dataSourceService.getDataSources()
192186
.stream()
193-
.map(Catalog::getName)
187+
.map(DataSource::getName)
194188
.collect(Collectors.toSet());
195-
CatalogSchemaIdentifierNameResolver catalogSchemaIdentifierNameResolver
196-
= new CatalogSchemaIdentifierNameResolver(qualifiedName.getParts(), allowedCatalogNames);
189+
DataSourceSchemaIdentifierNameResolver dataSourceSchemaIdentifierNameResolver
190+
= new DataSourceSchemaIdentifierNameResolver(qualifiedName.getParts(),
191+
allowedDataSourceNames);
197192

198193
FunctionName functionName
199-
= FunctionName.of(catalogSchemaIdentifierNameResolver.getIdentifierName());
194+
= FunctionName.of(dataSourceSchemaIdentifierNameResolver.getIdentifierName());
200195
List<Expression> arguments = node.getArguments().stream()
201196
.map(unresolvedExpression -> this.expressionAnalyzer.analyze(unresolvedExpression, context))
202197
.collect(Collectors.toList());
203198
TableFunctionImplementation tableFunctionImplementation
204199
= (TableFunctionImplementation) repository.compile(
205-
catalogSchemaIdentifierNameResolver.getCatalogName(), functionName, arguments);
200+
dataSourceSchemaIdentifierNameResolver.getDataSourceName(), functionName, arguments);
206201
context.push();
207202
TypeEnvironment curEnv = context.peek();
208203
Table table = tableFunctionImplementation.applyArguments();
209204
table.getFieldTypes().forEach((k, v) -> curEnv.define(new Symbol(Namespace.FIELD_NAME, k), v));
210205
curEnv.define(new Symbol(Namespace.INDEX_NAME,
211-
catalogSchemaIdentifierNameResolver.getIdentifierName()), STRUCT);
212-
return new LogicalRelation(catalogSchemaIdentifierNameResolver.getIdentifierName(),
206+
dataSourceSchemaIdentifierNameResolver.getIdentifierName()), STRUCT);
207+
return new LogicalRelation(dataSourceSchemaIdentifierNameResolver.getIdentifierName(),
213208
tableFunctionImplementation.applyArguments());
214209
}
215210

core/src/main/java/org/opensearch/sql/analysis/CatalogSchemaIdentifierNameResolver.java renamed to core/src/main/java/org/opensearch/sql/analysis/DataSourceSchemaIdentifierNameResolver.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,53 @@
1010
import java.util.List;
1111
import java.util.Set;
1212

13-
public class CatalogSchemaIdentifierNameResolver {
13+
public class DataSourceSchemaIdentifierNameResolver {
1414

15-
public static final String DEFAULT_CATALOG_NAME = "@opensearch";
15+
public static final String DEFAULT_DATASOURCE_NAME = "@opensearch";
1616
public static final String DEFAULT_SCHEMA_NAME = "default";
1717
public static final String INFORMATION_SCHEMA_NAME = "information_schema";
1818

19-
private String catalogName = DEFAULT_CATALOG_NAME;
19+
private String dataSourceName = DEFAULT_DATASOURCE_NAME;
2020
private String schemaName = DEFAULT_SCHEMA_NAME;
2121
private String identifierName;
2222

2323
private static final String DOT = ".";
2424

2525
/**
26-
* Data model for capturing catalog, schema and identifier from
26+
* Data model for capturing dataSourceName, schema and identifier from
2727
* fully qualifiedName. In the current state, it is used to capture
28-
* CatalogSchemaTable name and CatalogSchemaFunction in case of table
28+
* DataSourceSchemaTable name and DataSourceSchemaFunction in case of table
2929
* functions.
3030
*
3131
* @param parts parts of qualifiedName.
32-
* @param allowedCatalogs allowedCatalogs.
32+
* @param allowedDataSources allowedDataSources.
3333
*/
34-
public CatalogSchemaIdentifierNameResolver(List<String> parts, Set<String> allowedCatalogs) {
35-
List<String> remainingParts = captureSchemaName(captureCatalogName(parts, allowedCatalogs));
34+
public DataSourceSchemaIdentifierNameResolver(List<String> parts,
35+
Set<String> allowedDataSources) {
36+
List<String> remainingParts
37+
= captureSchemaName(captureDataSourceName(parts, allowedDataSources));
3638
identifierName = String.join(DOT, remainingParts);
3739
}
3840

3941
public String getIdentifierName() {
4042
return identifierName;
4143
}
4244

43-
public String getCatalogName() {
44-
return catalogName;
45+
public String getDataSourceName() {
46+
return dataSourceName;
4547
}
4648

4749
public String getSchemaName() {
4850
return schemaName;
4951
}
5052

5153

52-
// Capture catalog name and return remaining parts(schema name and table name)
54+
// Capture datasource name and return remaining parts(schema name and table name)
5355
// from the fully qualified name.
54-
private List<String> captureCatalogName(List<String> parts, Set<String> allowedCatalogs) {
55-
if (parts.size() > 1 && allowedCatalogs.contains(parts.get(0))
56-
|| DEFAULT_CATALOG_NAME.equals(parts.get(0))) {
57-
catalogName = parts.get(0);
56+
private List<String> captureDataSourceName(List<String> parts, Set<String> allowedDataSources) {
57+
if (parts.size() > 1 && allowedDataSources.contains(parts.get(0))
58+
|| DEFAULT_DATASOURCE_NAME.equals(parts.get(0))) {
59+
dataSourceName = parts.get(0);
5860
return parts.subList(1, parts.size());
5961
} else {
6062
return parts;

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.opensearch.sql.ast.expression.AggregateFunction;
2323
import org.opensearch.sql.ast.expression.AllFields;
2424
import org.opensearch.sql.ast.expression.And;
25-
import org.opensearch.sql.ast.expression.Argument;
2625
import org.opensearch.sql.ast.expression.Case;
2726
import org.opensearch.sql.ast.expression.Cast;
2827
import org.opensearch.sql.ast.expression.Compare;
@@ -74,7 +73,6 @@
7473
public class ExpressionAnalyzer extends AbstractNodeVisitor<Expression, AnalysisContext> {
7574
@Getter
7675
private final BuiltinFunctionRepository repository;
77-
private final DSL dsl;
7876

7977
@Override
8078
public Expression visitCast(Cast node, AnalysisContext context) {
@@ -86,7 +84,6 @@ public Expression visitCast(Cast node, AnalysisContext context) {
8684
public ExpressionAnalyzer(
8785
BuiltinFunctionRepository repository) {
8886
this.repository = repository;
89-
this.dsl = new DSL(repository);
9087
}
9188

9289
public Expression analyze(UnresolvedExpression unresolved, AnalysisContext context) {
@@ -103,7 +100,7 @@ public Expression visitEqualTo(EqualTo node, AnalysisContext context) {
103100
Expression left = node.getLeft().accept(this, context);
104101
Expression right = node.getRight().accept(this, context);
105102

106-
return dsl.equal(left, right);
103+
return DSL.equal(left, right);
107104
}
108105

109106
@Override
@@ -116,36 +113,36 @@ public Expression visitLiteral(Literal node, AnalysisContext context) {
116113
public Expression visitInterval(Interval node, AnalysisContext context) {
117114
Expression value = node.getValue().accept(this, context);
118115
Expression unit = DSL.literal(node.getUnit().name());
119-
return dsl.interval(value, unit);
116+
return DSL.interval(value, unit);
120117
}
121118

122119
@Override
123120
public Expression visitAnd(And node, AnalysisContext context) {
124121
Expression left = node.getLeft().accept(this, context);
125122
Expression right = node.getRight().accept(this, context);
126123

127-
return dsl.and(left, right);
124+
return DSL.and(left, right);
128125
}
129126

130127
@Override
131128
public Expression visitOr(Or node, AnalysisContext context) {
132129
Expression left = node.getLeft().accept(this, context);
133130
Expression right = node.getRight().accept(this, context);
134131

135-
return dsl.or(left, right);
132+
return DSL.or(left, right);
136133
}
137134

138135
@Override
139136
public Expression visitXor(Xor node, AnalysisContext context) {
140137
Expression left = node.getLeft().accept(this, context);
141138
Expression right = node.getRight().accept(this, context);
142139

143-
return dsl.xor(left, right);
140+
return DSL.xor(left, right);
144141
}
145142

146143
@Override
147144
public Expression visitNot(Not node, AnalysisContext context) {
148-
return dsl.not(node.getExpression().accept(this, context));
145+
return DSL.not(node.getExpression().accept(this, context));
149146
}
150147

151148
@Override
@@ -226,7 +223,7 @@ private Expression visitIn(
226223
if (valueList.size() == 1) {
227224
return visitCompare(new Compare("=", field, valueList.get(0)), context);
228225
} else if (valueList.size() > 1) {
229-
return dsl.or(
226+
return DSL.or(
230227
visitCompare(new Compare("=", field, valueList.get(0)), context),
231228
visitIn(field, valueList.subList(1, valueList.size()), context));
232229
} else {

0 commit comments

Comments
 (0)