Skip to content

Commit

Permalink
馃悰 source: airtable - handle singleSelect types (#22311)
Browse files Browse the repository at this point in the history
* add type for singleSelect

* default type fallback

* fmt

* bump and changelog

* use deepcopy

* auto-bump connector version

---------

Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
  • Loading branch information
pedroslopez and octavia-squidington-iii committed Feb 2, 2023
1 parent 4242c04 commit 2f6103e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- name: Airtable
sourceDefinitionId: 14c6e7ea-97ed-4f5e-a7b5-25e9a80b8212
dockerRepository: airbyte/source-airtable
dockerImageTag: 2.0.2
dockerImageTag: 2.0.3
documentationUrl: https://docs.airbyte.com/integrations/sources/airtable
icon: airtable.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-airtable:2.0.2"
- dockerImage: "airbyte/source-airtable:2.0.3"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/airtable"
connectionSpecification:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-airtable/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_airtable ./source_airtable
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=2.0.2
LABEL io.airbyte.version=2.0.3
LABEL io.airbyte.name=airbyte/source-airtable
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#


import logging
from copy import deepcopy
from typing import Any, Dict

from airbyte_cdk.models import AirbyteStream
from airbyte_cdk.models.airbyte_protocol import DestinationSyncMode, SyncMode

logger: logging.Logger = logging.getLogger("airbyte")


class SchemaTypes:

Expand Down Expand Up @@ -58,6 +60,7 @@ class SchemaTypes:
"rating": SchemaTypes.number,
"richText": SchemaTypes.string,
"singleLineText": SchemaTypes.string,
"singleSelect": SchemaTypes.string,
"externalSyncSource": SchemaTypes.string,
"url": SchemaTypes.string,
# referal default type
Expand Down Expand Up @@ -103,7 +106,11 @@ def get_json_schema(table: Dict[str, Any]) -> Dict[str, str]:
# Other edge cases, if `field_type` not in SIMPLE_AIRTABLE_TYPES, fall back to "simpleText" == `string`
# reference issue: https://github.com/airbytehq/oncall/issues/1432#issuecomment-1412743120
if complex_type == SchemaTypes.array_with_any:
complex_type["items"] = deepcopy(SIMPLE_AIRTABLE_TYPES.get(field_type))
if field_type in SIMPLE_AIRTABLE_TYPES:
complex_type["items"] = deepcopy(SIMPLE_AIRTABLE_TYPES.get(field_type))
else:
complex_type["items"] = SchemaTypes.string
logger.warning(f"Unknown field type: {field_type}, falling back to `simpleText` type")
properties.update(**{name: complex_type})
elif original_type in SIMPLE_AIRTABLE_TYPES.keys():
field_type: str = exec_type if exec_type else original_type
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/airtable.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ See information about rate limits [here](https://airtable.com/developers/web/api

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------|
| 2.0.3 | 2023-02-02 | [22311](https://github.com/airbytehq/airbyte/pull/22311) | Fix for `singleSelect` types when discovering the schema
| 2.0.2 | 2023-02-01 | [22245](https://github.com/airbytehq/airbyte/pull/22245) | Fix for empty `result` object when discovering the schema
| 2.0.1 | 2023-02-01 | [22224](https://github.com/airbytehq/airbyte/pull/22224) | Fixed broken `API Key` authentication
| 2.0.0 | 2023-01-27 | [21962](https://github.com/airbytehq/airbyte/pull/21962) | Added casting of native Airtable data types to JsonSchema types
Expand Down

0 comments on commit 2f6103e

Please sign in to comment.