ReExecute SQL using ADM

In this tutorial, you will learn how to ReExecute SQL on Snowflake. This ability can be quite useful for data engineers, because some errors are not resolved with a fix in the code. Take for example a locked User on execution or doubts that al scripts from your repository have been executed. Let’s get started!

One minute demo

Coming Soon!

Arrange

  • A working ADM Git repository

  • A valid ADM license added to the /environment directory

Act

Their are two type of actions when SQL needs to be ReExecuted:

Action Example situations

Error-Retry

SQL code is executed with a locked user

Redo SQL execution

When there is doubt whether a particular SQL script has been executed

Use the following steps to ReExecute an SQL script:

  • Remove the concerning SQL script from the /output directory

  • Commit the remove mutation

  • Push the change to the Git repository

Assert

After the push action to the repository, a new pipeline starts. The Template-stage will regenerate the removed SQL file and make a commit, triggering a subsequent pipeline. Notice that this pipeline contains more stages, one being an Executer-stage performing the ReExecute.

reexecute sql
Figure 1. ADM pipeline of the reexecution process

Observe the following series of events:

1 A change to the input directory is made in commit '0000001'
2 The change triggered a 1st process that succesfully completed (the Linting stage)
3 The change triggered a 2nd process that succesfully completed as well (Templating stage)
4 A change to the output directory is made by the Templater in commit '0000002'
5 ReExecution is done on the Test environment (Execute stage)

When clicking on the Executer-icon, the executed SQL code is shown in different colors (green for successfully executed statements, orange for comments and red for statements that resulted in an error)

reexecute sql log
Figure 2. ADM log output of the reexecution process