Skip to content

Commit

Permalink
Add Post Deployment Support for Snowflake App (#3296)
Browse files Browse the repository at this point in the history
  • Loading branch information
janeenyamak1 authored Jan 8, 2025
1 parent 2e62720 commit ac016ba
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-relationalStore-snowflake-pure</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-functionActivator-protocol</artifactId>
</dependency>
<dependency>
<groupId>org.finos.legend.engine</groupId>
<artifactId>legend-engine-xt-functionActivator-generation</artifactId>
</dependency>
<!-- ENGINE -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.impl.factory.Lists;
import org.finos.legend.engine.functionActivator.generation.FunctionActivatorGenerator;
import org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel;
import org.finos.legend.engine.plan.generation.PlanGenerator;
import org.finos.legend.engine.plan.platform.PlanPlatform;
import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent;
import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC;
import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContext;
import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData;
Expand All @@ -38,6 +40,8 @@
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.FunctionDefinition;
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.PackageableFunction;

import java.util.List;

public class SnowflakeAppGenerator
{

Expand All @@ -55,6 +59,7 @@ public static SnowflakeAppArtifact generateArtifact(PureModel pureModel, Root_me
}
}
SnowflakeAppContent content = new SnowflakeAppContent(activator._applicationName(), fullArtifact._createQuery(), fullArtifact._grantStatement(), activator._permissionScheme().toString(), activator._description(), ((Root_meta_external_function_activator_DeploymentOwnership)activator._ownership())._id(), Lists.mutable.withAll(fullArtifact._tables()));
List<ActionContent> actionContents = FunctionActivatorGenerator.generateActions(activator, pureModel);
if (activator._activationConfiguration() != null)
{
//identify connection
Expand All @@ -65,9 +70,9 @@ public static SnowflakeAppArtifact generateArtifact(PureModel pureModel, Root_me
.select(c -> c.getPath().equals(((org.finos.legend.engine.protocol.snowflakeApp.metamodel.SnowflakeAppDeploymentConfiguration)protocolActivator.activationConfiguration).activationConnection.connection)).getFirst().connectionValue;
SnowflakeDatasourceSpecification ds = (SnowflakeDatasourceSpecification)connection.datasourceSpecification;
String deployedLocation = String.format("https://app.%s.privatelink.snowflakecomputing.com/%s/%s/data/databases/%S", ds.region, ds.region, ds.accountName, ds.databaseName);
return new SnowflakeAppArtifact(content, new SnowflakeAppDeploymentConfiguration(connection), deployedLocation, sdlc);
return new SnowflakeAppArtifact(content, new SnowflakeAppDeploymentConfiguration(connection), deployedLocation, actionContents, sdlc);
}
return new SnowflakeAppArtifact(content, sdlc);
return new SnowflakeAppArtifact(content, actionContents, sdlc);
}

public static String generateFunctionLineage(PureModel pureModel, Root_meta_external_function_activator_snowflakeApp_SnowflakeApp activator, PureModelContext inputModel, Function<PureModel, RichIterable<? extends Root_meta_pure_extension_Extension>> routerExtensions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
package org.finos.legend.engine.protocol.snowflakeApp.deployment;

import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact;
import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent;
import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC;

import java.util.List;

public class SnowflakeAppArtifact extends FunctionActivatorArtifact
{
public String deployedLocation;
Expand All @@ -35,11 +38,28 @@ public SnowflakeAppArtifact(SnowflakeAppContent content, AlloySDLC sdlc)
}
}

public SnowflakeAppArtifact(SnowflakeAppContent content, List<ActionContent> actions, AlloySDLC sdlc)
{
this.content = content;
this.actions = actions;
if (sdlc != null)
{
this.version = getVersionInfo(sdlc);
}
}

public SnowflakeAppArtifact(SnowflakeAppContent content, SnowflakeAppDeploymentConfiguration config, String deployedLocation, AlloySDLC sdlc)
{
this(content, sdlc);
this.deploymentConfiguration = config;
this.deployedLocation = deployedLocation;
}

public SnowflakeAppArtifact(SnowflakeAppContent content, SnowflakeAppDeploymentConfiguration config, String deployedLocation, List<ActionContent> actions, AlloySDLC sdlc)
{
this(content, actions, sdlc);
this.deploymentConfiguration = config;
this.deployedLocation = deployedLocation;
}

}

0 comments on commit ac016ba

Please sign in to comment.