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

Test file formats #1392 #1768

Merged
merged 16 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
79d2d42
Test file formats #1392 - creating samples and test case
vitaliizazmic Jan 21, 2021
2929a7e
Test file formats #1392 - removing html form from supported
vitaliizazmic Jan 21, 2021
84ebf19
Google ads best practices #1568 - configured_catalog.json for each fi…
vitaliizazmic Jan 22, 2021
ec925d9
Test file formats #1392 - disabling integration test for temporary u…
vitaliizazmic Jan 22, 2021
b4bfaa0
add custom integration tests to CI
sherifnada Jan 22, 2021
0499905
Test file formats #1392 - fixing configs file path for existing gcs …
vitaliizazmic Jan 25, 2021
fb454da
Merge remote-tracking branch 'upstream/vitalii/1392_test_file_formats…
vitaliizazmic Jan 25, 2021
099bd6b
Merge branch 'master' into vitalii/1392_test_file_formats
vitaliizazmic Jan 27, 2021
e8ea7a1
Merge branch 'master' into vitalii/1392_test_file_formats
vitaliizazmic Jan 28, 2021
c14d78a
File source #1392 - merging with best practice
vitaliizazmic Jan 28, 2021
6e964a0
Merge branch 'master' into vitalii/1392_test_file_formats
vitaliizazmic Jan 29, 2021
bf60fc1
File source #1392 - removing samples, bumping version
vitaliizazmic Jan 29, 2021
8338b3c
Merge branch 'master' of github.com:airbytehq/airbyte into vitalii/13…
sherifnada Feb 1, 2021
f7d536d
File source #1392 - updating pyarrow version
vitaliizazmic Feb 2, 2021
dd87fe7
Merge remote-tracking branch 'upstream/vitalii/1392_test_file_formats…
vitaliizazmic Feb 2, 2021
ffdda03
File source #1392 - decrease pandas version to 1.2.0
vitaliizazmic Feb 2, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sourceDefinitionId": "778daa7c-feaf-4db6-96f3-70fd645acc77",
"name": "File",
"dockerRepository": "airbyte/source-file",
"dockerImageTag": "0.1.8",
"dockerImageTag": "0.1.9",
"documentationUrl": "https://hub.docker.com/r/airbyte/source-file"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- sourceDefinitionId: 778daa7c-feaf-4db6-96f3-70fd645acc77
name: File
dockerRepository: airbyte/source-file
dockerImageTag: 0.1.8
dockerImageTag: 0.1.9
documentationUrl: https://hub.docker.com/r/airbyte/source-file
- sourceDefinitionId: fdc8b827-3257-4b33-83cc-106d234c34d4
name: Google Adwords
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-file/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ COPY $CODE_PATH ./$CODE_PATH
COPY setup.py ./
RUN pip install ".[main]"

LABEL io.airbyte.version=0.1.8
LABEL io.airbyte.version=0.1.9
LABEL io.airbyte.name=airbyte/source-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""
MIT License

Copyright (c) 2020 Airbyte

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

from pathlib import Path

import pytest
from base_python import AirbyteLogger
from source_file import SourceFile
from source_file.client import Client

SAMPLE_DIRECTORY = Path(__file__).resolve().parent.joinpath("sample_files/formats")


def check_read(config, expected_columns=10, expected_rows=42):
client = Client(**config)
rows = list(client.read())
assert len(rows) == expected_rows
assert len(rows[0]) == expected_columns


@pytest.mark.parametrize(
"file_format, extension, expected_columns, expected_rows",
[
("csv", "csv", 8, 5000),
("json", "json", 2, 1),
("excel", "xls", 8, 50),
("excel", "xlsx", 8, 50),
("feather", "feather", 9, 3),
("parquet", "parquet", 9, 3),
],
)
def test_local_file_read(file_format, extension, expected_columns, expected_rows):
file_directory = SAMPLE_DIRECTORY.joinpath(file_format)
file_path = str(file_directory.joinpath(f"demo.{extension}"))
configs = {"dataset_name": "test", "format": file_format, "url": file_path, "provider": {"storage": "local"}}
check_read(configs, expected_columns, expected_rows)


def run_load_dataframes(config, expected_columns=10, expected_rows=42):
df_list = SourceFile.load_dataframes(config=config, logger=AirbyteLogger(), skip_data=False)
assert len(df_list) == 1 # Properly load 1 DataFrame
df = df_list[0]
assert len(df.columns) == expected_columns # DataFrame should have 10 columns
assert len(df.index) == expected_rows # DataFrame should have 42 rows of data
return df


def run_load_nested_json_schema(config, expected_columns=10, expected_rows=42):
data_list = SourceFile.load_nested_json(config, logger=AirbyteLogger())
assert len(data_list) == 1 # Properly load data
df = data_list[0]
assert len(df) == expected_rows # DataFrame should have 42 items
return df
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"streams": [
{
"stream": {
"name": "test",
"json_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Unnamed: 0": {
"type": "number"
},
"First Name": {
"type": "string"
},
"Last Name": {
"type": "string"
},
"Gender": {
"type": "string"
},
"Country": {
"type": "string"
},
"Age": {
"type": "number"
},
"Date": {
"type": "string"
},
"Id": {
"type": "number"
}
}
}
}
}
]
}
Loading