Skip to content

Commit

Permalink
fix: Windows fails with a path issue (#89)
Browse files Browse the repository at this point in the history
Fixes #87
  • Loading branch information
visch authored Jul 13, 2023
1 parent 73959e4 commit 97cb0c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit 97cb0c8

Please sign in to comment.