Skip to content

jbergeroncoveo/snowpark-java-scala

 
 

Repository files navigation

Build Status

Snowflake Snowpark Java & Scala API

The Snowpark library provides intuitive APIs for querying and processing data in a data pipeline. Using this library, you can build applications that process data in Snowflake without having to move data to the system where your application code runs.

Scala Java
Scala Developer Guide Java Developer Guide
Scala Tutorial
scaladoc (latest) javadoc (latest)

Getting Started

Have your Snowflake account ready

If you don't have a Snowflake account yet, you can sign up for a 30-day free trial account.

Prepare your local environment

Java 11 or Scala 2.12 is required. You can download Java 11 from the Eclipse foundation (formerly AdoptOpenJDK), and you can download Scala 2.11 from the Scala website.

Note that Java 17, Scala 2.13 and 3.x are currently not supported.

Install the library

Add the Snowpark SDK to your build file:

  • Maven

    <dependency>
        <groupId>com.snowflake</groupId>
        <artifactId>snowpark</artifactId>
        <version>1.8.0</version>
    </dependency>
  • Gradle

    implementation 'com.snowflake:snowpark:1.8.0'
  • sbt

    libraryDependencies += "com.snowflake" % "snowpark" % "1.8.0"

Create a session and start querying

For Java:

import com.snowflake.snowpark_java.*;
import java.util.HashMap;
import java.util.Map;

public class App 
{
    public static void main( String[] args )
    {
        Map<String, String> properties = new HashMap<>();
        properties.put("URL", "https://<account_identifier>.snowflakecomputing.com:443");
        properties.put("USER", "<user name>");
        properties.put("ROLE", "<role name>");
        properties.put("WAREHOUSE", "<warehouse name>");
        properties.put("DB", "<database name>");
        properties.put("SCHEMA", "<schema name>");
        Session session = Session.builder().configs(properties).create();

        session.sql("show tables").show();
    }
}

For Scala:

import com.snowflake.snowpark._
import com.snowflake.snowpark.functions._

object Main {
  def main(args: Array[String]): Unit = {
    // Replace the <placeholders> below.
    val configs = Map (
      "URL" -> "https://<account_identifier>.snowflakecomputing.com:443",
      "USER" -> "<user name>",
      "PASSWORD" -> "<password>",
      "ROLE" -> "<role name>",
      "WAREHOUSE" -> "<warehouse name>",
      "DB" -> "<database name>",
      "SCHEMA" -> "<schema name>"
    )
    val session = Session.builder.configs(configs).create
    session.sql("show tables").show()
  }
}

Contributing

To get involved, please see the contributing guide and check the open issues.

Test Report

Test Coverage

About

Snowflake Snowpark Java & Scala API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 63.0%
  • Java 36.4%
  • Other 0.6%