Setting Up IntelliJ IDEA CE for Snowpark Java¶
This topic explains how to set up IntelliJ IDEA CE for Snowpark.
Creating a New Maven Project in IntelliJ IDEA¶
Create a new Maven project for Snowpark.
-
Choose File » New » Project.
-
From the Project SDK menu, select 11 (for Java version 11).
Note that you don’t need to select an archetype. You can just leave the Create from archetype box unchecked.
-
Click Next.
-
Enter a name and location for your project (e.g.
hello-snowpark). -
Click Finish to create the new project.
Configuring the IntelliJ IDEA Project for Snowpark¶
Next, configure the project for Snowpark.
-
Open the
pom.xmlfile for the project. -
In the
<project>tag, add the tags to specify a dependency on the Snowpark library:<dependencies> ... <dependency> <groupId>com.snowflake</groupId> <artifactId>snowpark_2.12</artifactId> <version>1.18.0</version> </dependency> ... </dependencies> -
Save the changes to the
pom.xmlfile. -
Update your Maven repositories.
See Update Maven repositories (https://www.jetbrains.com/help/idea/troubleshooting-common-maven-issues.html#5e1bf655).
Verifying Your IntelliJ IDEA Project Configuration¶
To verify that you have configured your project to use Snowpark, run a simple example of Snowpark code.
-
In the Project tool window on the left (https://www.jetbrains.com/help/idea/2020.3/guided-tour-around-the-user-interface.html), expand your project, expand the
src/mainfolders, and select thejavafolder. -
Right-click on the folder, and choose New » Java class.
-
In the New Java Class dialog box, enter the name “HelloSnowpark”, select Class, and press the Enter key.
-
In the
HelloSnowpark.javafile, replace the contents with the code below:Note the following:
-
Replace the
placeholderswith values that you use to connect to Snowflake. -
For
account_identifier, specify your account identifier. -
If you prefer to use key pair authentication:
- Replace
PASSWORDwithPRIVATE_KEY_FILE, and set it to the path to your private key file. - If the private key is encrypted, you must set
PRIVATE_KEY_FILE_PWDto the passphrase for decrypting the private key.
As an alternative to setting
PRIVATE_KEY_FILEandPRIVATE_KEY_FILE_PWD, you can set thePRIVATEKEYproperty to the string value of the unencrypted private key from the private key file.- For example, if your private key file is unencrypted, set this to the value of the key in the file (without the
-----BEGIN PRIVATE KEY-----and-----END PRIVATE KEY-----header and footer and without the line endings). - Note that if the private key is encrypted, you must decrypt the key before setting it as the value of the
PRIVATEKEYproperty.
- Replace
-
-
Click the green arrow next to the
Classline, and choose Run HelloSnowpark.main() to run the example.