Skip to content

Commit

Permalink
Merge pull request #84 from stewartbryson/stewart
Browse files Browse the repository at this point in the history
Updated API docs.
  • Loading branch information
stewartbryson authored Apr 10, 2023
2 parents 7b98535 + d1bec9e commit 98a4294
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package io.github.stewartbryson
import groovy.util.logging.Slf4j

/**
* A domain container that allows for defining "Snowflake Applications." The plugin automatically creates the UDFs configured in this container.
* A domain container that allows for defining "Snowflake Applications." The plugin automatically creates the UDFs and procedures configured in this container.
*/
@Slf4j
class ApplicationContainer {
ApplicationContainer(final String name) {
this.name = name
}
/**
* The name of the domain container.
* The name of the domain container, which equates to the name of the function or procedure.
*/
String name
/**
Expand All @@ -27,7 +27,7 @@ class ApplicationContainer {
*/
String type = 'function'
/**
* The 'language' property of the UDF, currently only 'JAVA' is supported. DEFAULT: 'JAVA'.
* The 'language' property of the UDF. DEFAULT: 'JAVA'.
*/
String language = 'JAVA'
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import groovy.util.logging.Slf4j
import org.gradle.api.tasks.TaskAction

/**
* A superclass for creating Gradle tasks that use ephemeral Snowflake clones.
* A Gradle task for creating ephemeral testing environments in Snowflake.
*/
@Slf4j
abstract class CreateCloneTask extends SnowflakeTask {

/**
* Constructor.
*/
CreateCloneTask() {
description = "A Cacheable Gradle task for creating ephemeral testing environments in Snowflake."
description = "A Gradle task for creating ephemeral testing environments in Snowflake."
group = "verification"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import groovy.util.logging.Slf4j
import org.gradle.api.tasks.TaskAction

/**
* A superclass for creating Gradle tasks that use ephemeral Snowflake clones.
* A Gradle task for dropping ephemeral testing environments.
*/
@Slf4j
abstract class DropCloneTask extends SnowflakeTask {

/**
* Constructor.
*/
DropCloneTask() {
description = "A Cacheable Gradle task for dropping ephemeral testing environments in Snowflake."
description = "A Gradle task for dropping ephemeral testing environments in Snowflake."
group = "verification"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package io.github.stewartbryson
import groovy.util.logging.Slf4j
import org.ini4j.Ini

/**
* A class for parsing a SnowSQL config file.
*/
@Slf4j
class SnowConfig {
/**
Expand Down Expand Up @@ -56,6 +59,11 @@ class SnowConfig {
this.config = new File(config)
}

/**
* Build a Map of connection properties for making a Snowflake connection.
*
* @return Snowflake connection properties.
*/
Map getConnectionsProps() {
//Map props1 = [account: "account", user: "user", password: "password"]
Map props = [:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import groovy.util.logging.Slf4j
import java.sql.ResultSet
import java.sql.Statement

/**
* A class that manages connecting to Snowflake, as well as providing information about that connection. Used by core plugin tasks as well as the {@link SnowflakeSpec} specification.
*/
@Slf4j
class Snowflake {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class SnowflakeExtension {
private String projectName
private CiInformation ci

/**
* Constructor.
*
* @param project
*/
SnowflakeExtension(Project project) {
this.project = project
this.projectName = project.rootProject.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.sql.ResultSet
import java.sql.Statement

/**
* A Cacheable Gradle task for publishing UDFs to Snowflake.
* A Cacheable Gradle task for publishing UDFs and procedures to Snowflake.
*/
@Slf4j
@CacheableTask
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package io.github.stewartbryson

import groovy.util.logging.Slf4j
import spock.lang.Shared
import spock.lang.Specification

/**
* A Spock specification for functional testing in Snowflake.
*/
@Slf4j
class SnowflakeSpec extends Specification {

@Shared
Expand All @@ -14,6 +19,9 @@ class SnowflakeSpec extends Specification {
@Shared
private Snowflake snowflake = new Snowflake()

/**
* Built-in Spock method executed at the beginning of spec execution.
*/
def setupSpec() {
snowflake = new Snowflake(connection)
if (ephemeral) {
Expand All @@ -22,6 +30,11 @@ class SnowflakeSpec extends Specification {
}
}

/**
* Returns the first column of the first row of a SELECT statement. Useful for testing scalar function calls.
* @param sql
* @return The first column of the first row of a SELECT statement.
*/
def selectSingleValue(String sql) {
snowflake.getScalarValue(sql)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ abstract class SnowflakeTask extends DefaultTask {
log.warn "Reusing existing connection."
snowflake = project.session
}
snowflake.session
}
}
2 changes: 1 addition & 1 deletion src/markdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ features for teams already using Gradle in other areas of the organization.
It has three basic modes:

1. Lightweight publishing to internal Snowflake stages using Snowpark.
2. Slightly heavier publishing using external Snowflake stages and auto-configuration of
2. Slightly heavier publishing using external Snowflake stages and autoconfiguration of
the [`maven-publish`](https://docs.gradle.org/current/userguide/publishing_maven.html) plugin.
3. Publishing to Snowflake using external stages and custom configuration of
the [`maven-publish`](https://docs.gradle.org/current/userguide/publishing_maven.html) plugin.
Expand Down

0 comments on commit 98a4294

Please sign in to comment.