Home > OS >  Call Snowsql procedure via shell script
Call Snowsql procedure via shell script

Time:11-12

I'm trying to call a Snowflake procedure via shell script. For that I need to

  1. connect to my data warehouse
  2. call my procedure

Here's my .sh file:

#bin/bash
BASE_DIR=/opt/analytics
JOBS_DIR=$BASE_DIR/jobs

#call snowsql proc
snowsql -q CALL calculateduration();

I have configured my Snowflake connection parameters in the config file, so I do not need any arguments to connect to the data warehouse, such as snowsql -a -u -d

To connect, i simply type snowsql

What my shell script should do is

  1. command: snowsql
  2. call calculateduration() which is in a file e.g. durations.sql;

In Postgres it would be something like this

psql -U user -d db -f "$JOBS_DIR/sql/calculatedurations.sql"

Unfortunately, I'm not able to make it work with Snowsql.

Thank you!

CodePudding user response:

In case someone needs this...

I was able to make this work by storing my procedure call in a file and executing that file with the -f arguments that snowsql offers.

My .sh file

#bin/bash
JOBS_DIR=$BASE_DIR/jobs

#call snowsql proc
snowsql -f "$JOBS_DIR/dbscripts/calculateDurations.sql"

CodePudding user response:

Using full qualified identifier should do the trick. So please try to add Database as well as Schemaname in front.

  • Related