Skip to content

Commit

Permalink
Adding google code changes for core/src/main/java/org/opensearch/sql/…
Browse files Browse the repository at this point in the history
…analysis core/src/main/java/org/opensearch/sql/ast core/src/main/java/org/opensearch/sql/data

 core/src/main/java/org/opensearch/sql/datasource

Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale committed Jul 25, 2023
1 parent af12c02 commit 25bfe09
Show file tree
Hide file tree
Showing 111 changed files with 757 additions and 1,245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.analysis;

import java.util.ArrayList;
Expand All @@ -13,26 +12,22 @@
import org.opensearch.sql.expression.NamedExpression;
import org.opensearch.sql.expression.function.FunctionProperties;

/**
* The context used for Analyzer.
*/
/** The context used for Analyzer. */
public class AnalysisContext {
/**
* Environment stack for symbol scope management.
*/
/** Environment stack for symbol scope management. */
private TypeEnvironment environment;
@Getter
private final List<NamedExpression> namedParseExpressions;

@Getter
private final FunctionProperties functionProperties;
@Getter private final List<NamedExpression> namedParseExpressions;

@Getter private final FunctionProperties functionProperties;

public AnalysisContext() {
this(new TypeEnvironment(null));
}

/**
* Class CTOR.
*
* @param environment Env to set to a new instance.
*/
public AnalysisContext(TypeEnvironment environment) {
Expand All @@ -41,9 +36,7 @@ public AnalysisContext(TypeEnvironment environment) {
this.functionProperties = new FunctionProperties();
}

/**
* Push a new environment.
*/
/** Push a new environment. */
public void push() {
environment = new TypeEnvironment(environment);
}
Expand Down
242 changes: 120 additions & 122 deletions core/src/main/java/org/opensearch/sql/analysis/Analyzer.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@

package org.opensearch.sql.analysis;

import com.google.common.collect.ImmutableSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.opensearch.sql.ast.expression.QualifiedName;
import org.opensearch.sql.datasource.DataSourceService;
import org.opensearch.sql.datasource.model.DataSourceMetadata;

public class DataSourceSchemaIdentifierNameResolver {

Expand All @@ -29,19 +24,17 @@ public class DataSourceSchemaIdentifierNameResolver {
private static final String DOT = ".";

/**
* Data model for capturing dataSourceName, schema and identifier from
* fully qualifiedName. In the current state, it is used to capture
* DataSourceSchemaTable name and DataSourceSchemaFunction in case of table
* functions.
* Data model for capturing dataSourceName, schema and identifier from fully qualifiedName. In the
* current state, it is used to capture DataSourceSchemaTable name and DataSourceSchemaFunction in
* case of table functions.
*
* @param dataSourceService {@link DataSourceService}.
* @param parts parts of qualifiedName.
* @param parts parts of qualifiedName.
*/
public DataSourceSchemaIdentifierNameResolver(DataSourceService dataSourceService,
List<String> parts) {
public DataSourceSchemaIdentifierNameResolver(
DataSourceService dataSourceService, List<String> parts) {
this.dataSourceService = dataSourceService;
List<String> remainingParts
= captureSchemaName(captureDataSourceName(parts));
List<String> remainingParts = captureSchemaName(captureDataSourceName(parts));
identifierName = String.join(DOT, remainingParts);
}

Expand All @@ -57,7 +50,6 @@ public String getSchemaName() {
return schemaName;
}


// Capture datasource name and return remaining parts(schema name and table name)
// from the fully qualified name.
private List<String> captureDataSourceName(List<String> parts) {
Expand All @@ -74,12 +66,11 @@ private List<String> captureDataSourceName(List<String> parts) {
private List<String> captureSchemaName(List<String> parts) {
if (parts.size() > 1
&& (DEFAULT_SCHEMA_NAME.equals(parts.get(0))
|| INFORMATION_SCHEMA_NAME.contains(parts.get(0)))) {
|| INFORMATION_SCHEMA_NAME.contains(parts.get(0)))) {
schemaName = parts.get(0);
return parts.subList(1, parts.size());
} else {
return parts;
}
}

}
Loading

0 comments on commit 25bfe09

Please sign in to comment.