Giter Site home page Giter Site logo

snowproc's Introduction

SnowProc

npm

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.

Installation and setup

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 {
    rights =  Rights.Caller;

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

Building

Compile with:

npx snowproc-compile

Output will be located in the directory specified in tsconfig.json (default: dist)

create procedure SimpleTest(arg STRING)
	returns variant
	language javascript
	execute as Owner
	as
$$
// a lot of boilerplate you don't need to write
class Arguments {
}
class SimpleTest extends Procedure {
    constructor() {
        super(...arguments);
        this.run = (client, args) => {
            // your code
        };
    }
}
const proc = new SimpleTest();
const args = { arg: ARG };
const client = new SnowflakeClient();
return proc.run(client, args);
$$;

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

snowproc's People

Contributors

dependabot[bot] avatar thijskoot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

snowproc's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.