-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Source File - add support for custom encoding (#15293)
* added support for custom encoding * fixed unit test for utf16 * updated docs * bumped connector version * auto-bump connector version [ci skip] Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
- Loading branch information
1 parent
bbf3584
commit f143c8f
Showing
8 changed files
with
74 additions
and
42 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
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
Binary file added
BIN
+132 Bytes
airbyte-integrations/connectors/source-file/integration_tests/sample_files/test_utf16.csv
Binary file not shown.
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
35 changes: 35 additions & 0 deletions
35
airbyte-integrations/connectors/source-file/unit_tests/test_source.py
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,35 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import logging | ||
from pathlib import Path | ||
|
||
from source_file.source import SourceFile | ||
|
||
HERE = Path(__file__).parent.absolute() | ||
|
||
|
||
def test_csv_with_utf16_encoding(): | ||
|
||
config_local_csv_utf16 = { | ||
"dataset_name": "AAA", | ||
"format": "csv", | ||
"reader_options": '{"encoding":"utf_16"}', | ||
"url": f"{HERE}/../integration_tests/sample_files/test_utf16.csv", | ||
"provider": {"storage": "local"}, | ||
} | ||
expected_schema = { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"properties": { | ||
"header1": {"type": ["string", "null"]}, | ||
"header2": {"type": ["number", "null"]}, | ||
"header3": {"type": ["number", "null"]}, | ||
"header4": {"type": ["boolean", "null"]}, | ||
}, | ||
"type": "object", | ||
} | ||
|
||
catalog = SourceFile().discover(logger=logging.getLogger("airbyte"), config=config_local_csv_utf16) | ||
stream = next(iter(catalog.streams)) | ||
assert stream.json_schema == expected_schema |
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