-
Notifications
You must be signed in to change notification settings - Fork 58
Chore: New example sync to snowflake Cortex #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 8 commits
399fa09
42a0dad
7de9ca1
e9b7016
860f30a
0cde86a
1b5184e
df24a7a
85590cb
74f5e4c
6dfc5b9
b048edc
ddd699e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
""" | ||
Usage: | ||
poetry install | ||
poetry run python examples/run_snowflake_destination.py | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import airbyte as ab | ||
from airbyte.caches import SnowflakeCache | ||
from airbyte.secrets.google_gsm import GoogleGSMSecretManager | ||
|
||
SCALE = 100 | ||
|
||
|
||
AIRBYTE_INTERNAL_GCP_PROJECT = "dataline-integration-testing" | ||
secret_mgr = GoogleGSMSecretManager( | ||
project=AIRBYTE_INTERNAL_GCP_PROJECT, | ||
credentials_json=ab.get_secret("GCP_GSM_CREDENTIALS"), | ||
) | ||
|
||
secret = secret_mgr.get_secret( | ||
secret_name="AIRBYTE_LIB_SNOWFLAKE_CREDS", | ||
) | ||
assert secret is not None, "Secret not found." | ||
secret_config = secret.parse_json() | ||
|
||
snowflake_destination_secret = secret_mgr.fetch_connector_secret( | ||
connector_name="destination-snowflake", | ||
).parse_json() | ||
cortex_destination_secret = secret_mgr.fetch_connector_secret( | ||
connector_name="destination-snowflake-cortex", | ||
).parse_json() | ||
|
||
|
||
source = ab.get_source( | ||
"source-faker", | ||
config={ | ||
"count": SCALE, | ||
}, | ||
install_if_missing=True, | ||
streams=["products", "users"], | ||
) | ||
cache = SnowflakeCache( | ||
account=secret_config["account"], | ||
username=secret_config["username"], | ||
password=secret_config["password"], | ||
database=secret_config["database"], | ||
warehouse=secret_config["warehouse"], | ||
role=secret_config["role"], | ||
) | ||
snowflake_destination = ab.get_destination( | ||
"destination-snowflake", | ||
config={ | ||
**snowflake_destination_secret, | ||
"default_schema": "pyairbyte_tests", | ||
}, | ||
) | ||
cortex_destination_secret["processing"]["text_fields"] = [ | ||
"make", | ||
"model", | ||
"name", | ||
"gender", | ||
] | ||
cortex_destination_secret["indexing"]["default_schema"] = "pyairbyte_tests" | ||
cortex_destination = ab.get_destination( | ||
"destination-snowflake-cortex", | ||
config=cortex_destination_secret, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider focusing on one destination type? The setup for both Snowflake and Cortex destinations is comprehensive. For a demo script, though, we might want to keep things as simple as possible. What do you think about focusing on just one destination type? Maybe we could have separate example scripts for Snowflake and Cortex? This could make each example more focused and easier to follow. Wdyt? If you agree, we could either:
|
||
# cortex_destination.print_config_spec() | ||
# snowflake_destination.print_config_spec() | ||
# cortex_destination.print_config_spec() | ||
snowflake_destination.check() | ||
cortex_destination.check() | ||
source.check() | ||
|
||
# # This works: | ||
# snowflake_write_result = snowflake_destination.write( | ||
# source, | ||
# cache=False, # Toggle comment to test with/without caching | ||
# ) | ||
|
||
cortex_write_result = cortex_destination.write( | ||
source, | ||
cache=False, # Toggle comment to test with/without caching | ||
) | ||
|
||
# result = source.read(cache) | ||
|
||
# for name in ["products"]: | ||
# print(f"Stream {name}: {len(list(result[name]))} records") |
Uh oh!
There was an error while loading. Please reload this page.