Skip to content

Instantly share code, notes, and snippets.

View zdravko-il's full-sized avatar

Zdravko Yanakiev zdravko-il

View GitHub Profile
CREATE MASKING POLICY hash_mask AS (val string) RETURNS string -> SHA2(val);
ALTER TABLE customer MODIFY COLUMN name SET MASKING POLICY hash_mask,
ALTER TABLE customer MODIFY COLUMN email SET MASKING POLICY hash_mask;
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/customer/v1.json",
"type": "object",
"title": "Customer event",
"properties": {
"name": {
"type": "string",
"description": "Customer's full name",
"tags": [
# Bad practice - max overwrites the built-in Python function:
from snowflake.snowpark.functions import max
# Recommended import style:
import snowflake.snowpark.functions as F
import snowflake.snowpark.types as T
# Or use an alias to import a single function
from snowflake.snowpark.functions import max as snf_max
e2etest-job:
stage: e2etest
only:
- branches
image: zyanakiev/snowpark-devops:latest
script:
- |
jq -c -r '.assertions[]' tests/e2e_tests.json | while read test; do
name=$(jq -r '.name' <<< $test)
sql=$(jq -r '.value' <<< $test)
release-model-job:
stage: release
image: zyanakiev/snowpark-devops:latest
artifacts:
name: model
when: on_success
paths:
- model_$CI_COMMIT_TAG.joblib
rules:
- if: $CI_COMMIT_TAG # Only on new tag
run-procedures-job:
stage: run-procedures
image: zyanakiev/snowpark-devops:latest
only:
- branches
script:
- |
echo "Run procedures"
~/bin/snowsql -s $SF_SCHEMA -f ./setup/01_run_procedures.sql -o friendly=false -o exit_on_error=true
delete-schema-job:
stage: deploy
variables:
GIT_STRATEGY: none
environment:
name: $CI_COMMIT_REF_SLUG
action: stop
only:
- branches
image: zyanakiev/snowpark-devops:latest
deploy-job:
stage: deploy
image: zyanakiev/snowpark-devops:latest
environment:
name: $CI_COMMIT_REF_SLUG
on_stop: delete-schema-job
only:
- branches
script:
- |
build-job:
stage: build
image: zyanakiev/snowpark-devops:latest
artifacts:
name: app
untracked: false
when: on_success
expire_in: "7 days"
paths:
- "app.zip"
schema-name-job:
stage: .pre
script:
- SF_SCHEMA="$(echo $CI_COMMIT_REF_NAME | sed -E 's/[^[:alnum:]]+/_/g')"
- echo "SF_SCHEMA=${SF_SCHEMA}" > variables.env
artifacts:
reports:
dotenv: variables.env