Skip to content

Commit

Permalink
Legend SQl - add new source providers (#2413)
Browse files Browse the repository at this point in the history
  • Loading branch information
gs-jp1 authored Oct 30, 2023
1 parent 27ff539 commit 4d620e4
Show file tree
Hide file tree
Showing 50 changed files with 2,931 additions and 54 deletions.
16 changes: 16 additions & 0 deletions legend-engine-config/legend-engine-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,22 @@
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-sql-query</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-sql-providers-relationalStore</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-sql-providers-service</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-sql-providers-core</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-sql-providers-shared</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-test-data-generation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
import org.finos.legend.engine.external.shared.format.model.api.ExternalFormats;
import org.finos.legend.engine.functionActivator.api.FunctionActivatorAPI;
import org.finos.legend.engine.generation.artifact.api.ArtifactGenerationExtensionApi;
import org.finos.legend.engine.language.hostedService.api.HostedServiceService;
import org.finos.legend.engine.language.hostedService.deployment.HostedServiceDeploymentConfiguration;
import org.finos.legend.engine.language.pure.compiler.api.Compile;
import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel;
import org.finos.legend.engine.language.pure.grammar.api.grammarToJson.GrammarToJson;
Expand All @@ -95,6 +97,8 @@
import org.finos.legend.engine.language.pure.modelManager.ModelManager;
import org.finos.legend.engine.language.pure.modelManager.sdlc.SDLCLoader;
import org.finos.legend.engine.language.pure.relational.api.relationalElement.RelationalElementAPI;
import org.finos.legend.engine.language.snowflakeApp.api.SnowflakeAppService;
import org.finos.legend.engine.language.snowflakeApp.deployment.SnowflakeAppDeploymentConfiguration;
import org.finos.legend.engine.plan.execution.PlanExecutor;
import org.finos.legend.engine.plan.execution.api.ExecutePlanLegacy;
import org.finos.legend.engine.plan.execution.api.ExecutePlanStrategic;
Expand All @@ -120,19 +124,20 @@
import org.finos.legend.engine.plan.execution.stores.service.plugin.ServiceStoreExecutor;
import org.finos.legend.engine.plan.execution.stores.service.plugin.ServiceStoreExecutorBuilder;
import org.finos.legend.engine.plan.generation.extension.PlanGeneratorExtension;
import org.finos.legend.engine.language.hostedService.api.HostedServiceService;
import org.finos.legend.engine.language.hostedService.deployment.HostedServiceDeploymentConfiguration;
import org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory;
import org.finos.legend.engine.protocol.pure.v1.model.PureProtocol;
import org.finos.legend.engine.language.snowflakeApp.api.SnowflakeAppService;
import org.finos.legend.engine.language.snowflakeApp.deployment.SnowflakeAppDeploymentConfiguration;
import org.finos.legend.engine.pure.code.core.PureCoreExtensionLoader;
import org.finos.legend.engine.query.graphQL.api.debug.GraphQLDebug;
import org.finos.legend.engine.query.graphQL.api.execute.GraphQLExecute;
import org.finos.legend.engine.query.graphQL.api.grammar.GraphQLGrammar;
import org.finos.legend.engine.query.pure.api.Execute;
import org.finos.legend.engine.query.sql.api.SQLExecutor;
import org.finos.legend.engine.query.sql.api.execute.SqlExecute;
import org.finos.legend.engine.query.sql.api.grammar.SqlGrammar;
import org.finos.legend.engine.query.sql.providers.LegendServiceSQLSourceProvider;
import org.finos.legend.engine.query.sql.providers.RelationalStoreSQLSourceProvider;
import org.finos.legend.engine.query.sql.providers.shared.FunctionSQLSourceProvider;
import org.finos.legend.engine.query.sql.providers.shared.project.ProjectCoordinateLoader;
import org.finos.legend.engine.server.core.ServerShared;
import org.finos.legend.engine.server.core.api.CurrentUser;
import org.finos.legend.engine.server.core.api.Info;
Expand Down Expand Up @@ -388,7 +393,12 @@ public void run(T serverConfiguration, Environment environment)
environment.jersey().register(new GraphQLDebug(modelManager, serverConfiguration.metadataserver, routerExtensions));

// SQL
environment.jersey().register(new SqlExecute(modelManager, planExecutor, routerExtensions, FastList.newListWith(), generatorExtensions.flatCollect(PlanGeneratorExtension::getExtraPlanTransformers)));
ProjectCoordinateLoader projectCoordinateLoader = new ProjectCoordinateLoader(modelManager, serverConfiguration.metadataserver.getSdlc());
environment.jersey().register(new SqlExecute(new SQLExecutor(modelManager, planExecutor, routerExtensions, FastList.newListWith(
new RelationalStoreSQLSourceProvider(projectCoordinateLoader),
new FunctionSQLSourceProvider(projectCoordinateLoader),
new LegendServiceSQLSourceProvider(projectCoordinateLoader)),
generatorExtensions.flatCollect(PlanGeneratorExtension::getExtraPlanTransformers))));
environment.jersey().register(new SqlGrammar());

// Service
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2022 Goldman Sachs
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-sql-providers</artifactId>
<version>4.32.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>legend-engine-xt-sql-providers-core</artifactId>
<packaging>jar</packaging>
<name>Legend Engine - XT - SQL - Providers - Core</name>

<dependencies>

<!-- ENGINE -->
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-protocol-pure</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-sql-protocol</artifactId>
</dependency>
<!-- ENGINE -->

<!-- ECLIPSE COLLECTIONS -->
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
</dependency>
<!-- ECLIPSE COLLECTIONS -->

<!-- AUTHENTICATION -->
<dependency>
<groupId>org.pac4j</groupId>
<artifactId>pac4j-core</artifactId>
</dependency>
<!-- AUTHENTICATION -->

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<!-- TEST -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- TEST -->
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2023 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package org.finos.legend.engine.query.sql.api.sources;

import org.finos.legend.engine.protocol.sql.metamodel.Node;

/**
* @deprecated
* Use {@link org.finos.legend.engine.query.sql.providers.core.SQLContext}
*/
@Deprecated
public class SQLContext extends org.finos.legend.engine.query.sql.providers.core.SQLContext
{
public SQLContext(Node query)
{
super(query);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2023 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package org.finos.legend.engine.query.sql.api.sources;

import org.eclipse.collections.impl.utility.ListIterate;
import org.finos.legend.engine.protocol.pure.v1.model.executionOption.ExecutionOption;
import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.Runtime;
import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Lambda;
import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.executionContext.ExecutionContext;

import java.util.List;

/**
* @deprecated
* Use {@link org.finos.legend.engine.query.sql.providers.core.SQLSource}
*/
@Deprecated
public class SQLSource extends org.finos.legend.engine.query.sql.providers.core.SQLSource
{
public SQLSource(String type, Lambda func, String mapping, Runtime runtime, List<ExecutionOption> executionOptions, List<SQLSourceArgument> key)
{
this(type, func, mapping, runtime, executionOptions, null, key);
}

public SQLSource(String type, Lambda func, String mapping, Runtime runtime, List<ExecutionOption> executionOptions, ExecutionContext executionContext, List<SQLSourceArgument> key)
{
super(type, func, mapping, runtime, executionOptions, executionContext, ListIterate.collect(key, k -> new org.finos.legend.engine.query.sql.providers.core.SQLSourceArgument(k.getName(), k.getIndex(), k.getValue())));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2023 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package org.finos.legend.engine.query.sql.api.sources;

/**
* @deprecated
* Use {@link org.finos.legend.engine.query.sql.providers.core.SQLSourceArgument}
*/
@Deprecated
public class SQLSourceArgument extends org.finos.legend.engine.query.sql.providers.core.SQLSourceArgument
{
public SQLSourceArgument(String name, Integer index, Object value)
{
super(name, index, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@

package org.finos.legend.engine.query.sql.api.sources;

import org.eclipse.collections.api.list.MutableList;
import org.pac4j.core.profile.CommonProfile;

import java.util.List;

public interface SQLSourceProvider
/**
* @deprecated
* Use {@link org.finos.legend.engine.query.sql.providers.core.SQLSourceProvider}
*/
@Deprecated
public interface SQLSourceProvider extends org.finos.legend.engine.query.sql.providers.core.SQLSourceProvider
{
String getType();

SQLSourceResolvedContext resolve(List<TableSource> sources, SQLContext context, MutableList<CommonProfile> profiles);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2023 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package org.finos.legend.engine.query.sql.api.sources;

import org.eclipse.collections.impl.list.mutable.FastList;
import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContext;

import java.util.List;

/**
* @deprecated
* Use {@link org.finos.legend.engine.query.sql.providers.core.SQLSourceResolvedContext}
*/
@Deprecated
public class SQLSourceResolvedContext
{
private final List<PureModelContext> pureModelContexts;
private final List<SQLSource> sources;

public SQLSourceResolvedContext(PureModelContext pureModelContext, List<SQLSource> sources)
{
this(FastList.newListWith(pureModelContext), sources);
}

public SQLSourceResolvedContext(List<PureModelContext> pureModelContexts, List<SQLSource> sources)
{
this.pureModelContexts = pureModelContexts != null ? pureModelContexts : FastList.newList();
this.sources = sources;
}

@Deprecated
public PureModelContext getPureModelContext()
{
return pureModelContexts.get(0);
}

public List<PureModelContext> getPureModelContexts()
{
return pureModelContexts;
}

public List<SQLSource> getSources()
{
return sources;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
import java.util.List;
import java.util.Optional;

/**
* @deprecated
* Use {@link org.finos.legend.engine.query.sql.providers.core.TableSource}
*/
@Deprecated
public class TableSource
{
private final String type;
Expand Down Expand Up @@ -81,4 +86,4 @@ public String toString()
{
return ToStringBuilder.reflectionToString(this);
}
}
}
Loading

0 comments on commit 4d620e4

Please sign in to comment.