-
Notifications
You must be signed in to change notification settings - Fork 30
feat(query_properties): Add configured catalog to SimpleRetriever and only fetch properties that are included in the stream schema #788
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
Merged
brianjlai
merged 8 commits into
main
from
brian/property_chunking_only_fetch_enabled_fields
Oct 23, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a3b3563
add configured catalog to SimpleRetriever and only fetch properties t…
brianjlai de0b73f
fix tests and clean up a few parts of the code
brianjlai 15d8769
introduce a JsonSchemaPropertySelector component to allow for more fl…
brianjlai 901a313
Merge branch 'main' into brian/property_chunking_only_fetch_enabled_f…
brianjlai 4b872d6
fix tests
brianjlai df6dd69
Merge branch 'main' into brian/property_chunking_only_fetch_enabled_f…
brianjlai 19f4cf7
pr feedback and bug fix so we always include properties if no propert…
brianjlai afc67fd
don't modify the original schema when we run transforms
brianjlai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
10 changes: 10 additions & 0 deletions
10
airbyte_cdk/sources/declarative/requesters/query_properties/property_selector/__init__.py
This file contains hidden or 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,10 @@ | ||
| # Copyright (c) 2025 Airbyte, Inc., all rights reserved. | ||
|
|
||
| from airbyte_cdk.sources.declarative.requesters.query_properties.property_selector.json_schema_property_selector import ( | ||
| JsonSchemaPropertySelector, | ||
| ) | ||
| from airbyte_cdk.sources.declarative.requesters.query_properties.property_selector.property_selector import ( | ||
| PropertySelector, | ||
| ) | ||
|
|
||
| __all__ = ["JsonSchemaPropertySelector", "PropertySelector"] |
54 changes: 54 additions & 0 deletions
54
...eclarative/requesters/query_properties/property_selector/json_schema_property_selector.py
This file contains hidden or 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,54 @@ | ||
| # Copyright (c) 2025 Airbyte, Inc., all rights reserved. | ||
| import copy | ||
| from dataclasses import InitVar, dataclass, field | ||
| from typing import Any, List, Mapping, Optional, Set | ||
|
|
||
| from airbyte_protocol_dataclasses.models import ConfiguredAirbyteStream | ||
|
|
||
| from airbyte_cdk.sources.declarative.requesters.query_properties.property_selector.property_selector import ( | ||
| PropertySelector, | ||
| ) | ||
| from airbyte_cdk.sources.declarative.transformations import RecordTransformation | ||
| from airbyte_cdk.sources.types import Config | ||
|
|
||
|
|
||
| @dataclass | ||
| class JsonSchemaPropertySelector(PropertySelector): | ||
| """ | ||
| A class that contains a list of transformations to apply to properties. | ||
| """ | ||
|
|
||
| config: Config | ||
| parameters: InitVar[Mapping[str, Any]] | ||
| # For other non-read operations, there is no configured catalog and therefore no schema selection | ||
| configured_stream: Optional[ConfiguredAirbyteStream] = None | ||
| properties_transformations: List[RecordTransformation] = field(default_factory=lambda: []) | ||
|
|
||
| def __post_init__(self, parameters: Mapping[str, Any]) -> None: | ||
| self._parameters = parameters | ||
|
|
||
| def select(self) -> Optional[Set[str]]: | ||
| """ | ||
| Returns the set of properties that have been selected for the configured stream. The intent being that | ||
| we should only query for selected properties not all since disabled properties are discarded. | ||
|
|
||
| When configured_stream is None, then there was no incoming catalog and all fields should be retrieved. | ||
| This is different from the empty set where the json_schema was empty and no schema fields were selected. | ||
| """ | ||
|
|
||
| # For CHECK/DISCOVER operations, there is no catalog and therefore no configured stream or selected | ||
| # columns. In this case we return None which is interpreted by the QueryProperties component to not | ||
| # perform any filtering of schema properties and fetch all of them | ||
| if self.configured_stream is None: | ||
| return None | ||
|
|
||
| schema_properties = copy.deepcopy( | ||
| self.configured_stream.stream.json_schema.get("properties", {}) | ||
| ) | ||
| if self.properties_transformations: | ||
| for transformation in self.properties_transformations: | ||
| transformation.transform( | ||
| record=schema_properties, | ||
| config=self.config, | ||
| ) | ||
| return set(schema_properties.keys()) |
24 changes: 24 additions & 0 deletions
24
...dk/sources/declarative/requesters/query_properties/property_selector/property_selector.py
This file contains hidden or 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,24 @@ | ||
| # Copyright (c) 2025 Airbyte, Inc., all rights reserved. | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from dataclasses import dataclass | ||
| from typing import Optional, Set | ||
|
|
||
|
|
||
| @dataclass | ||
| class PropertySelector(ABC): | ||
| """ | ||
| Describes the interface for selecting and transforming properties from a configured stream's schema | ||
| to determine which properties should be queried from the API. | ||
| """ | ||
|
|
||
| @abstractmethod | ||
| def select(self) -> Optional[Set[str]]: | ||
| """ | ||
| Selects and returns the set of properties that should be queried from the API based on the | ||
| configured stream's schema and any applicable transformations. | ||
|
|
||
| Returns: | ||
| Set[str]: The set of property names to query | ||
| """ | ||
| pass |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.