Skip to content

Commit 97cb0c8

Browse files
authored
fix: Windows fails with a path issue (#89)
Fixes #87
1 parent 73959e4 commit 97cb0c8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ jobs:
1414
TARGET_SNOWFLAKE_WAREHOUSE: ${{secrets.TARGET_SNOWFLAKE_WAREHOUSE}}
1515
TARGET_SNOWFLAKE_ROLE: ${{secrets.TARGET_SNOWFLAKE_ROLE}}
1616
strategy:
17+
fail-fast: false
1718
matrix:
1819
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
20+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
1921
steps:
2022
- uses: actions/checkout@v3
2123
- name: Set up Python ${{ matrix.python-version }}

target_snowflake/connector.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
from target_snowflake.snowflake_types import NUMBER, TIMESTAMP_NTZ, VARIANT
1515

16-
1716
SNOWFLAKE_MAX_STRING_LENGTH = 16777216
1817

1918
class TypeMap:
@@ -270,7 +269,7 @@ def schema_exists(self, schema_name: str) -> bool:
270269

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

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

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

0 commit comments

Comments
 (0)