-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 🎉 Source Airtable: migrate to the
Metadata API
for dynamic schema…
… generation (#20846)
- Loading branch information
Showing
18 changed files
with
695 additions
and
286 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
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
32 changes: 20 additions & 12 deletions
32
airbyte-integrations/connectors/source-airtable/acceptance-test-config.yml
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 |
---|---|---|
@@ -1,20 +1,28 @@ | ||
# See [Source Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/source-acceptance-tests-reference) | ||
# for more information about how to configure these tests | ||
connector_image: airbyte/source-airtable:dev | ||
tests: | ||
acceptance_tests: | ||
spec: | ||
- spec_path: "source_airtable/spec.json" | ||
tests: | ||
- spec_path: "source_airtable/spec.json" | ||
connection: | ||
- config_path: "secrets/config.json" | ||
status: "succeed" | ||
- config_path: "integration_tests/invalid_config.json" | ||
status: "failed" | ||
tests: | ||
- config_path: "secrets/config.json" | ||
status: "succeed" | ||
- config_path: "integration_tests/invalid_config.json" | ||
status: "failed" | ||
discovery: | ||
- config_path: "secrets/config.json" | ||
tests: | ||
- config_path: "secrets/config.json" | ||
# bypassed this check, because discovery mechanism was changed | ||
backward_compatibility_tests_config: | ||
disable_for_version: "0.1.3" | ||
basic_read: | ||
- config_path: "secrets/config.json" | ||
configured_catalog_path: "integration_tests/configured_catalog.json" | ||
empty_streams: [] | ||
tests: | ||
- config_path: "secrets/config.json" | ||
configured_catalog_path: "integration_tests/configured_catalog.json" | ||
empty_streams: [] | ||
full_refresh: | ||
- config_path: "secrets/config.json" | ||
configured_catalog_path: "integration_tests/configured_catalog.json" | ||
tests: | ||
- config_path: "secrets/config.json" | ||
configured_catalog_path: "integration_tests/configured_catalog.json" |
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
4 changes: 1 addition & 3 deletions
4
airbyte-integrations/connectors/source-airtable/integration_tests/invalid_config.json
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
{ | ||
"api_key": "key####################", | ||
"base_id": "app####################", | ||
"tables": ["Table 1", "Table 2"] | ||
"api_key": "key123456" | ||
} |
4 changes: 1 addition & 3 deletions
4
airbyte-integrations/connectors/source-airtable/integration_tests/sample_config.json
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
{ | ||
"api_key": "key1234567890", | ||
"base_id": "app1234567890", | ||
"tables": ["Table 1", "Table 2"] | ||
"api_key": "key1234567890" | ||
} |
61 changes: 0 additions & 61 deletions
61
airbyte-integrations/connectors/source-airtable/source_airtable/helpers.py
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
airbyte-integrations/connectors/source-airtable/source_airtable/schema_helpers.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,44 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
|
||
from typing import Any, Dict | ||
|
||
from airbyte_cdk.models import AirbyteStream | ||
from airbyte_cdk.models.airbyte_protocol import DestinationSyncMode, SyncMode | ||
|
||
|
||
class SchemaHelpers: | ||
@staticmethod | ||
def clean_name(name_str: str) -> str: | ||
return name_str.replace(" ", "_").lower().strip() | ||
|
||
@staticmethod | ||
def get_json_schema(table: Dict[str, Any]) -> Dict[str, str]: | ||
fields = table.get("fields", {}) | ||
properties = { | ||
"_airtable_id": {"type": ["null", "string"]}, | ||
"_airtable_created_time": {"type": ["null", "string"]}, | ||
} | ||
|
||
for field in fields: | ||
field_name = SchemaHelpers.clean_name(field.get("name")) | ||
properties[field_name] = {"type": ["null", "string"]} | ||
|
||
json_schema = { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"additionalProperties": True, | ||
"properties": properties, | ||
} | ||
return json_schema | ||
|
||
@staticmethod | ||
def get_airbyte_stream(stream_name: str, json_schema: Dict[str, Any]) -> AirbyteStream: | ||
return AirbyteStream( | ||
name=stream_name, | ||
json_schema=json_schema, | ||
supported_sync_modes=[SyncMode.full_refresh], | ||
supported_destination_sync_modes=[DestinationSyncMode.overwrite, DestinationSyncMode.append_dedup], | ||
) |
Oops, something went wrong.