forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Guian Gumpac <guian.gumpac@improving.com>
- Loading branch information
Showing
10 changed files
with
528 additions
and
59 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
core/src/main/java/org/opensearch/sql/datasource/model/EmptyDataSourceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package org.opensearch.sql.datasource.model; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import org.opensearch.sql.data.type.ExprType; | ||
import org.opensearch.sql.datasource.DataSourceService; | ||
import org.opensearch.sql.planner.logical.LogicalPlan; | ||
import org.opensearch.sql.planner.physical.PhysicalPlan; | ||
import org.opensearch.sql.storage.StorageEngine; | ||
import org.opensearch.sql.storage.Table; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import static org.opensearch.sql.analysis.DataSourceSchemaIdentifierNameResolver.DEFAULT_DATASOURCE_NAME; | ||
import static org.opensearch.sql.data.type.ExprCoreType.STRING; | ||
|
||
public class EmptyDataSourceService { | ||
private static DataSourceService emptyDataSourceService = new DataSourceService() { | ||
@Override | ||
public DataSource getDataSource(String dataSourceName) { | ||
return new DataSource(DEFAULT_DATASOURCE_NAME, DataSourceType.OPENSEARCH, storageEngine()); | ||
} | ||
|
||
@Override | ||
public Set<DataSourceMetadata> getDataSourceMetadata(boolean isDefaultDataSourceRequired) { | ||
return Set.of(); | ||
} | ||
|
||
@Override | ||
public DataSourceMetadata getDataSourceMetadata(String name) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void createDataSource(DataSourceMetadata metadata) { | ||
|
||
} | ||
|
||
@Override | ||
public void updateDataSource(DataSourceMetadata dataSourceMetadata) { | ||
|
||
} | ||
|
||
@Override | ||
public void deleteDataSource(String dataSourceName) { | ||
|
||
} | ||
|
||
@Override | ||
public Boolean dataSourceExists(String dataSourceName) { | ||
return null; | ||
} | ||
}; | ||
|
||
private static StorageEngine storageEngine() { | ||
Table table = | ||
new Table() { | ||
@Override | ||
public boolean exists() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void create(Map<String, ExprType> schema) { | ||
throw new UnsupportedOperationException("Create table is not supported"); | ||
} | ||
|
||
@Override | ||
public Map<String, ExprType> getFieldTypes() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public PhysicalPlan implement(LogicalPlan plan) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public Map<String, ExprType> getReservedFieldTypes() { | ||
return ImmutableMap.of("_test", STRING); | ||
} | ||
}; | ||
return (dataSourceSchemaName, tableName) -> table; | ||
} | ||
|
||
|
||
public static DataSourceService getEmptyDataSourceService() { | ||
return emptyDataSourceService; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
core/src/main/java/org/opensearch/sql/expression/function/NestedFunctionResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.expression.function; | ||
|
||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.opensearch.sql.data.model.ExprValue; | ||
import org.opensearch.sql.data.type.ExprType; | ||
import org.opensearch.sql.expression.Expression; | ||
import org.opensearch.sql.expression.FunctionExpression; | ||
import org.opensearch.sql.expression.env.Environment; | ||
|
||
public class NestedFunctionResolver implements FunctionResolver{ | ||
@Override | ||
public Pair<FunctionSignature, FunctionBuilder> resolve(FunctionSignature unresolvedSignature) { | ||
return Pair.of(unresolvedSignature, | ||
(functionProperties, arguments) -> | ||
new FunctionExpression(BuiltinFunctionName.NESTED.getName(), arguments) { | ||
@Override | ||
public ExprValue valueOf(Environment<Expression, ExprValue> valueEnv) { | ||
return valueEnv.resolve(getArguments().get(0)); | ||
} | ||
|
||
@Override | ||
public ExprType type() { | ||
return getArguments().get(0).type(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public FunctionName getFunctionName() { | ||
return BuiltinFunctionName.NESTED.getName(); | ||
} | ||
} |
Oops, something went wrong.