Skip to content
Thijs edited this page Nov 6, 2019 · 2 revisions

SnowProc

Stored procedures for Snowflake written in Typescript. Extends the native JS APIs provided by Snowflake and provides a more streamlined, less error-prone method of writing stored procedures. SnowProc's helpful classes and abstractions reduce the amount of boilerplate you need to write in order to concisely express your logic.

Compiles down to native JavaScript and creates a DML-statement.

Documentation and examples in the wiki.

Installing SnowProc

Install:

    npm install snowproc

Scaffold a new project:

    npx snowproc-new

Example

import { Arguments, Procedure, SnowflakeClient } from 'snowproc';

export class ProcArgs extends Arguments {
    stringArg: string;
    dateArg: Date;
    numArg: number;
}

export class DemoProcedure extends Procedure {
    args: ProcArgs;
    rights =  Rights.Caller;

    run = () => {
        var results = new SnowflakeClient()
            .execute('show databases')
            .materialize();
        
        return <any>{queryResults: results, arguments: this.args}
    }
}

Building

Compile with:

npx snowproc-compile

Current limitations

  • Parameterized queries not supported as of yet
  • QueryResult can only be materialized/looped through once
    • Possible solution: use resultscan of query id when next() returns false
Clone this wiki locally