Skip to content
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

fix: Windows fails with a path issue #89

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ jobs:
TARGET_SNOWFLAKE_WAREHOUSE: ${{secrets.TARGET_SNOWFLAKE_WAREHOUSE}}
TARGET_SNOWFLAKE_ROLE: ${{secrets.TARGET_SNOWFLAKE_ROLE}}
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
7 changes: 4 additions & 3 deletions target_snowflake/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from target_snowflake.snowflake_types import NUMBER, TIMESTAMP_NTZ, VARIANT


SNOWFLAKE_MAX_STRING_LENGTH = 16777216

class TypeMap:
Expand Down Expand Up @@ -270,7 +269,7 @@ def schema_exists(self, schema_name: str) -> bool:

def _get_put_statement(self, sync_id: str, file_uri: str) -> Tuple[text, dict]:
"""Get Snowflake PUT statement."""
return (text(f"put '{file_uri}' '@~/target-snowflake/{sync_id}'"), {})
return (text(f"put :file_uri '@~/target-snowflake/{sync_id}'"), {})

def _get_column_selections(self, schema: dict, formatter: SnowflakeIdentifierPreparer) -> list:
column_selections = []
Expand Down Expand Up @@ -372,7 +371,9 @@ def put_batches_to_stage(self, sync_id: str, files: Sequence[str]) -> None:
put_statement, kwargs = self._get_put_statement(
sync_id=sync_id, file_uri=file_uri
)
conn.execute(put_statement, **kwargs)
# sqlalchemy.text stripped a slash, which caused windows to fail so we used bound parameters instead
# See https://github.com/MeltanoLabs/target-snowflake/issues/87 for more information about this error
conn.execute(put_statement, file_uri=file_uri, **kwargs)

def create_file_format(self, file_format: str) -> None:
"""Create a file format in the schema.
Expand Down