-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bugfixes --------- Co-authored-by: TJ Murphy <[email protected]>
- Loading branch information
Showing
60 changed files
with
1,034 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Test and Lint Python Package | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
workflow_call: | ||
secrets: | ||
TEST_SNOWFLAKE_ACCOUNT: | ||
required: true | ||
TEST_SNOWFLAKE_USER: | ||
required: true | ||
TEST_SNOWFLAKE_PASSWORD: | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Create a virtual environment | ||
run: | | ||
python -m venv .venv | ||
- name: Install dependencies | ||
run: | | ||
source ./.venv/bin/activate | ||
python -m pip install --upgrade pip | ||
make install-dev | ||
- name: Run checks (linter, code style, tests) | ||
run: | | ||
source ./.venv/bin/activate | ||
make check | ||
integration: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
environment: [snowflake-aws-enterprise, snowflake-aws-standard] | ||
environment: ${{ matrix.environment }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
- name: Create a virtual environment | ||
run: | | ||
python -m venv .venv | ||
- name: Install dependencies | ||
run: | | ||
source ./.venv/bin/activate | ||
python -m pip install --upgrade pip | ||
make install-dev | ||
- name: Run integration tests | ||
run: | | ||
source ./.venv/bin/activate | ||
make integration | ||
env: | ||
TEST_SNOWFLAKE_ACCOUNT: ${{ secrets.TEST_SNOWFLAKE_ACCOUNT }} | ||
TEST_SNOWFLAKE_USER: ${{ secrets.TEST_SNOWFLAKE_USER }} | ||
TEST_SNOWFLAKE_PASSWORD: ${{ secrets.TEST_SNOWFLAKE_PASSWORD }} | ||
TEST_SNOWFLAKE_ROLE: ACCOUNTADMIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# How to install Titan | ||
|
||
Snowflake app (preferred) | ||
|
||
```SQL | ||
-- AWS | ||
CREATE STAGE titan_aws URL = 's3://titan-snowflake/'; | ||
EXECUTE IMMEDIATE FROM @titan_aws/install; | ||
|
||
-- Google Cloud | ||
CREATE STORAGE INTEGRATION titan_storage_int | ||
TYPE = EXTERNAL_STAGE | ||
STORAGE_PROVIDER = 'GCS' | ||
ENABLED = TRUE | ||
STORAGE_ALLOWED_LOCATIONS = ('gcs://titan-snowflake/') | ||
; | ||
|
||
CREATE STAGE titan_gcp | ||
URL = 'gcs://titan-snowflake/' | ||
STORAGE_INTEGRATION = titan_storage_int; | ||
|
||
EXECUTE IMMEDIATE | ||
FROM @titan_gcp/install; | ||
``` | ||
|
||
|
||
Python package via pip | ||
|
||
```sh | ||
pip install https://github.com/teej/titan/archive/main.zip | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.PHONY: install install-dev test integration style check | ||
|
||
install: | ||
pip install -e . | ||
|
||
install-dev: | ||
pip install -e ".[dev]" | ||
|
||
test: | ||
python -m pytest | ||
|
||
integration: | ||
python -m pytest --snowflake | ||
|
||
style: | ||
python -m black . | ||
|
||
check: style test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--snowflake", | ||
action="store_true", | ||
default=False, | ||
help="Runs tests that require a Snowflake connection", | ||
) | ||
|
||
|
||
def pytest_runtest_setup(item): | ||
if "requires_snowflake" in item.keywords and not item.config.getoption("--snowflake"): | ||
pytest.skip("need --snowflake option to run this test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
CREATE DATABASE titan; | ||
|
||
CREATE PROCEDURE titan.public.install() | ||
RETURNS OBJECT NOT NULL | ||
LANGUAGE PYTHON | ||
RUNTIME_VERSION = '3.9' | ||
PACKAGES = ('snowflake-snowpark-python') | ||
IMPORTS = ('@TITAN/titan-latest.zip') | ||
HANDLER = 'titan.spi.install' | ||
EXECUTE AS CALLER | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,13 @@ create account myaccount1 | |
first_name = Jane | ||
last_name = Smith | ||
email = '[email protected]' | ||
edition = enterprise | ||
region = aws_us_west_2; | ||
-- edition = enterprise | ||
-- region = aws_us_west_2 | ||
; | ||
|
||
create account myaccount2 | ||
admin_name = admin | ||
admin_password = 'TestPassword1' | ||
email = '[email protected]' | ||
edition = enterprise; | ||
-- edition = enterprise | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
create or replace procedure clean_table(table_name STRING) | ||
returns int | ||
language python | ||
runtime_version = '3.8' | ||
packages = ('snowflake-snowpark-python') | ||
handler = 'clean_table_handler' | ||
AS | ||
$$ | ||
import snowflake.snowpark | ||
|
||
def clean_table_handler(session: snowflake.snowpark.session.Session, | ||
table_name: str) -> int: | ||
table = session.table(table_name) | ||
result = table.delete(~table['fruit'].rlike('[a-z]+')) | ||
# equivalent to `DELETE FROM dirty_data WHERE fruit NOT RLIKE '[a-z]+';` | ||
|
||
return result.rows_deleted | ||
$$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.