Skip to content

Commit 02de837

Browse files
authored
Merge branch 'main' into docs/add-missing-macros-to-component-schema
2 parents fec0baa + b148ca5 commit 02de837

File tree

85 files changed

+1830
-411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1830
-411
lines changed

.github/workflows/connector-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ jobs:
7575
# Chargebee is being flaky:
7676
# - connector: source-chargebee
7777
# cdk_extra: n/a
78-
# These two are behind in CDK updates and can't be used as tests until they are updated:
79-
# - connector: source-s3
80-
# cdk_extra: file-based
78+
# This one is behind in CDK updates and can't be used as tests until it is updated:
8179
# - connector: destination-pinecone
8280
# cdk_extra: vector-db-based
81+
- connector: source-google-drive
82+
cdk_extra: file-based
8383
- connector: destination-motherduck
8484
cdk_extra: sql
8585
# ZenDesk currently failing (as of 2024-12-02)

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ repos:
3636
- id: check-toml
3737

3838
- repo: https://github.com/astral-sh/ruff-pre-commit
39-
rev: v0.8.3
39+
rev: v0.11.5
4040
hooks:
4141
# Run the linter with repo-defined settings
4242
- id: ruff

airbyte_cdk/connector_builder/connector_builder_handler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
from dataclasses import asdict, dataclass, field
7-
from typing import Any, Dict, List, Mapping
7+
from typing import Any, ClassVar, Dict, List, Mapping
88

99
from airbyte_cdk.connector_builder.test_reader import TestReader
1010
from airbyte_cdk.models import (
@@ -37,6 +37,8 @@
3737

3838
@dataclass
3939
class TestLimits:
40+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
41+
4042
max_records: int = field(default=DEFAULT_MAXIMUM_RECORDS)
4143
max_pages_per_slice: int = field(default=DEFAULT_MAXIMUM_NUMBER_OF_PAGES_PER_SLICE)
4244
max_slices: int = field(default=DEFAULT_MAXIMUM_NUMBER_OF_SLICES)

airbyte_cdk/connector_builder/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def handle_connector_builder_request(
7878
if command == "resolve_manifest":
7979
return resolve_manifest(source)
8080
elif command == "test_read":
81-
assert (
82-
catalog is not None
83-
), "`test_read` requires a valid `ConfiguredAirbyteCatalog`, got None."
81+
assert catalog is not None, (
82+
"`test_read` requires a valid `ConfiguredAirbyteCatalog`, got None."
83+
)
8484
return read_stream(source, config, catalog, state, limits)
8585
elif command == "full_resolve_manifest":
8686
return full_resolve_manifest(source, limits)

airbyte_cdk/connector_builder/test_reader/reader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
import logging
7-
from typing import Any, Dict, Iterator, List, Mapping, Optional, Union
7+
from typing import Any, ClassVar, Dict, Iterator, List, Mapping, Optional, Union
88

99
from airbyte_cdk.connector_builder.models import (
1010
AuxiliaryRequest,
@@ -66,6 +66,8 @@ class TestReader:
6666
6767
"""
6868

69+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
70+
6971
logger = logging.getLogger("airbyte.connector-builder")
7072

7173
def __init__(

airbyte_cdk/sources/concurrent_source/concurrent_source.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def create(
4949
too_many_generator = (
5050
not is_single_threaded and initial_number_of_partitions_to_generate >= num_workers
5151
)
52-
assert (
53-
not too_many_generator
54-
), "It is required to have more workers than threads generating partitions"
52+
assert not too_many_generator, (
53+
"It is required to have more workers than threads generating partitions"
54+
)
5555
threadpool = ThreadPoolManager(
5656
concurrent.futures.ThreadPoolExecutor(
5757
max_workers=num_workers, thread_name_prefix="workerpool"

airbyte_cdk/sources/declarative/auth/oauth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ def get_token_expiry_date(self) -> AirbyteDateTime:
239239
def _has_access_token_been_initialized(self) -> bool:
240240
return self._access_token is not None
241241

242-
def set_token_expiry_date(self, value: Union[str, int]) -> None:
243-
self._token_expiry_date = self._parse_token_expiration_date(value)
242+
def set_token_expiry_date(self, value: AirbyteDateTime) -> None:
243+
self._token_expiry_date = value
244244

245245
def get_assertion_name(self) -> str:
246246
return self.assertion_name

airbyte_cdk/sources/declarative/concurrent_declarative_source.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
from airbyte_cdk.sources.declarative.extractors.record_filter import (
2020
ClientSideIncrementalRecordFilterDecorator,
2121
)
22-
from airbyte_cdk.sources.declarative.incremental import ConcurrentPerPartitionCursor
22+
from airbyte_cdk.sources.declarative.incremental import (
23+
ConcurrentPerPartitionCursor,
24+
GlobalSubstreamCursor,
25+
)
2326
from airbyte_cdk.sources.declarative.incremental.datetime_based_cursor import DatetimeBasedCursor
2427
from airbyte_cdk.sources.declarative.incremental.per_partition_with_global import (
2528
PerPartitionWithGlobalCursor,
@@ -361,7 +364,8 @@ def _group_streams(
361364
== DatetimeBasedCursorModel.__name__
362365
and hasattr(declarative_stream.retriever, "stream_slicer")
363366
and isinstance(
364-
declarative_stream.retriever.stream_slicer, PerPartitionWithGlobalCursor
367+
declarative_stream.retriever.stream_slicer,
368+
(GlobalSubstreamCursor, PerPartitionWithGlobalCursor),
365369
)
366370
):
367371
stream_state = self._connector_state_manager.get_stream_state(

airbyte_cdk/sources/declarative/declarative_component_schema.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,27 @@ definitions:
23072307
$parameters:
23082308
type: object
23092309
additionalProperties: true
2310+
KeyTransformation:
2311+
title: Transformation to apply for extracted object keys by Dpath Flatten Fields
2312+
type: object
2313+
required:
2314+
- type
2315+
properties:
2316+
type:
2317+
type: string
2318+
enum: [ KeyTransformation ]
2319+
prefix:
2320+
title: Key Prefix
2321+
description: Prefix to add for object keys. If not provided original keys remain unchanged.
2322+
type: string
2323+
examples:
2324+
- flattened_
2325+
suffix:
2326+
title: Key Suffix
2327+
description: Suffix to add for object keys. If not provided original keys remain unchanged.
2328+
type: string
2329+
examples:
2330+
- _flattened
23102331
DpathFlattenFields:
23112332
title: Dpath Flatten Fields
23122333
description: A transformation that flatten field values to the to top of the record.
@@ -2335,6 +2356,11 @@ definitions:
23352356
title: Replace Origin Record
23362357
description: Whether to replace the origin record or not. Default is False.
23372358
type: boolean
2359+
key_transformation:
2360+
title: Key transformation
2361+
description: Transformation for object keys. If not provided, original key will be used.
2362+
type: object
2363+
"$ref": "#/definitions/KeyTransformation"
23382364
$parameters:
23392365
type: object
23402366
additionalProperties: true

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,25 @@ class FlattenFields(BaseModel):
879879
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
880880

881881

882+
class KeyTransformation(BaseModel):
883+
prefix: Optional[Union[str, None]] = Field(
884+
None,
885+
description="Prefix to add for object keys. If not provided original keys remain unchanged.",
886+
examples=[
887+
"flattened_",
888+
],
889+
title="Key Prefix",
890+
)
891+
suffix: Optional[Union[str, None]] = Field(
892+
None,
893+
description="Suffix to add for object keys. If not provided original keys remain unchanged.",
894+
examples=[
895+
"_flattened",
896+
],
897+
title="Key Suffix",
898+
)
899+
900+
882901
class DpathFlattenFields(BaseModel):
883902
type: Literal["DpathFlattenFields"]
884903
field_path: List[str] = Field(
@@ -897,6 +916,11 @@ class DpathFlattenFields(BaseModel):
897916
description="Whether to replace the origin record or not. Default is False.",
898917
title="Replace Origin Record",
899918
)
919+
key_transformation: Optional[Union[KeyTransformation, None]] = Field(
920+
None,
921+
description="Transformation for object keys. If not provided, original key will be used.",
922+
title="Key transformation",
923+
)
900924
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
901925

902926

0 commit comments

Comments
 (0)