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

[Low Code CDK] Pass DeclarativeStream's name into DefaultSchemaLoader #21516

Merged
merged 1 commit into from
Jan 20, 2023

Conversation

clnoll
Copy link
Contributor

@clnoll clnoll commented Jan 18, 2023

Closes #21381

What

Fixes an issue where the CDK is not identifying the default schema location if a schema loader is not defined.

How

Problem: when streams is invoked from

self._constructor.create_component(DeclarativeStreamModel, stream_config, config)
with a manifest that does not define a schema loader, self._constructor.create_component creates a DeclarativeStream object; however, it is not created with the options attribute. The DeclarativeStream object creates a DefaultSchemaLoader downstream, which resolves to a JsonSchemaLoader. JsonSchemaLoader attempts to identify the path to local stream schema files; it does this by reading the "name" key from options. But, when options is not present, we return "", and so are attempting to find a file called .json, whereas we want the file name to default to <stream name>.json.

This fixes the problem by passing DeclarativeStream.name to the DefaultSchemaLoader.

@clnoll clnoll requested a review from a team as a code owner January 18, 2023 11:20
@clnoll clnoll requested a review from brianjlai January 18, 2023 11:20
@octavia-squidington-iv octavia-squidington-iv added the CDK Connector Development Kit label Jan 18, 2023
@clnoll clnoll force-pushed the fix-missing-stream-name branch from 1ba7a5d to 98dd111 Compare January 18, 2023 12:02
def __post_init__(self, name: str, options: Mapping[str, Any]):
options = options or {}
if "name" not in options:
options["name"] = name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If name is defined, why not use self.name directly at https://github.com/airbytehq/airbyte/pull/21516/files#diff-eebfee995e9a963a52d517c0ebcab9579872dee179cf961719740e6c3fdddc9fR48 instead of self._options.get("name", "") that was generating the error? Do we need the options at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name isn't available on self here, and at least for now for consistency with the rest of the factory we do want to override model.name if options is provided and includes it. Removing options is a possible refactor but felt out of scope for this PR (we've talked about doing a larger effort to remove it where it's not needed as there are various places where that's the case).

Copy link
Contributor

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding to my previous review:
Conditional approval: it feels like there is overlapping concerns with options and name and to avoid breaking the interface, I'm wondering if we could just have a different error message here when we don't have the name. If it would be possible to clean this overlapping concerns or just remove one of the fields, I think it would be great. In any case, I trust your judgement to change this or not

Copy link
Contributor

@brianjlai brianjlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, but nothing blocking from my side

model_type=DeclarativeStreamModel, component_definition=propagated_source_config, config=input_config
)
schema_loader = stream.schema_loader
assert schema_loader.default_loader._get_json_filepath().split("/")[-1] == f"{stream.name}.json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to test the entire string, not just the final part just to be comprehensive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Done.

Also handles the case where `DeclarativeStream.options` is `None`.
@clnoll clnoll force-pushed the fix-missing-stream-name branch from 98dd111 to 25d1893 Compare January 20, 2023 11:46
@clnoll clnoll merged commit de91191 into master Jan 20, 2023
@clnoll clnoll deleted the fix-missing-stream-name branch January 20, 2023 12:05
clnoll added a commit that referenced this pull request Jan 20, 2023
clnoll added a commit that referenced this pull request Jan 20, 2023
clnoll added a commit that referenced this pull request Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit team/extensibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connector builder server: No records returned if no schema loader is defined for a stream
4 participants