Scala UDF handler project and packaging¶
You can make handler code projects easier to maintain by using a well-organized project hierarchy and popular build tools. These are useful when you intend to copy handler code to a Snowflake stage, then refer to it from functions and procedures.
To build and package handler code, you can use popular tools such as sbt, Maven, and Gradle. For more information, refer to the following topics:
Once you’ve packaged handler code, you can add it to a stage as described in Making dependencies available to your code.
For more information on choosing whether to keep your handler in-line or on a stage, refer to Keeping handler code in-line or on a stage.
Organize your files¶
If you intend to package your handler in a JAR file and put it on a Snowflake stage, you might find it useful to use a project hierarchy that organizes Snowflake handler code. This section suggests a hierarchy for organizing files.
For a GitHub template you can use to create a project hierarchy like this one, refer to the Snowflake-Labs GitHub repository.
SnowflakeProject
|-- project
| |-- plugins.sbt
|-- src
| |-- main / scala / org / example
| | |-- function
| | | |-- FunctionHandler.scala
| | |-- procedure
| | |-- utils
| |-- test / scala / org / example
| | |-- function
| | |-- procedure
|-- build.sbt
|-- pom.xml
The following table describes the sections of the hierarchy.
Directory/File |
Description |
---|---|
|
Contains files used by sbt to guide build and packaging of code.
|
|
Contains handler code source files.
|
|
Contains handler test source files.
|
|
Specifies the build definition used by sbt, including name and version of the built output, dependencies, and so on. For more information, refer to Packaging Scala Handler Code with sbt. |
|
Specifies the build definition used by Maven. For more information, refer to Packaging Java or Scala Handler Code with Maven. |