Skip to main content
Version: v3.2 print this page

Code Templates

Amorphic Code Templates provide a quick way to create boilerplate code and parameterized scripts that can be attached to resources. They help streamline the code creation process by offering ready-to-use code structures that can be customized as needed.

Introduction

Creating a Code Template

To create a new code template:

  1. Navigate to the Templates page and switch to the Code Templates tab
  2. Click the Create Template button in the top-right corner
  3. Fill in the Template Details:
AttributeDescription
Template NameEnter a unique name for the code template
DescriptionAdd a description explaining what the code template does
Template ArgumentsArguments which will fill up the placeholder values in the user provided code snippets
  1. In the next Script Editor panel, upload the required script file to be used as code template. Upon upload, user is free to update it in the same editor panel.
  2. Click Save to create a code template

Create code template

System Code Templates

The following system code templates are available by default:

Template NameDescription
Amorphic Datasets to Snowflake and Iceberg Data TransferTransferring data from Amorphic datasets to Snowflake and Iceberg formats
DB2(AS400) to Snowflake Data TransferTransferring data from DB2(AS400) database to Snowflake
MariaDB to Snowflake Data TransferTransferring data from MariaDB database to Snowflake
MariaDB to Amorphic Iceberg Dataset TransferTransferring data from MariaDB database to Amorphic Iceberg dataset format
DB2(AS400) to Amorphic Iceberg Dataset TransferTransferring data from DB2(AS400) database to Amorphic Iceberg dataset format
Multi-Database Schema SynchronizationSynchronizing schemas across multiple databases

View Code Template

When viewing a code template, you can see the following sections:

  • Template Parameters: This section will have the parameters defined for usage of that template
  • Template Code: This section will contain the preview of the template uploaded

It also displays the actions to refresh, edit, share, and delete the code template. These actions are only applicable for user-created templates; users cannot edit or delete system-generated code templates.

View code template

Updating a Code Template

User can freely update the template parameters or code for the template. To modify an existing code template:

  1. Modify the Template Code
  2. Click Save to update the code template

Update Template code/parameters

danger
  • System code templates cannot be edited or deleted
  • Only user-created templates can be modified or removed
  • Be cautious when deleting templates as this action cannot be undone

Using Code Templates

To use a code template:

  1. Navigate to the appropriate section (ETL Jobs)
  2. Click Create New and select From Template
  3. Choose the desired resource template (e.g., Python shell job or Spark job)
  4. Customize the parameters and placeholders
  5. In the Script Editor, users have two options: either select the code template or write their own script
  6. Save and execute as needed

Using Code Template

info

With this job creation process, the job creation is a one-step process and the job will go to the registered status.

Deleting a Code Template

To remove a code template:

  1. Click the delete icon (trash) in the Actions column
  2. A confirmation dialog will appear
  3. Click Delete Code Template to confirm

Delete code template

Best Practices

Best Practices
  • Use clear, descriptive names for code templates
  • Include comprehensive comments and documentation within the code
  • Use meaningful variable names and placeholders
  • Test the template by creating code from it after making changes
  • Follow coding standards and conventions for the selected language
  • Include error handling and logging in your templates
  • Make templates reusable and parameterized
  • Document any dependencies or requirements