-
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.
Enable low-code CDK users to specify schema in the manifest (#20375)
Enable low-code CDK users to specify schema in the manifest Also update documentation: * Add inline schema loader info to yaml-overview.md * Include inline schema info in tutorial
- Loading branch information
Showing
11 changed files
with
77 additions
and
6 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
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
19 changes: 19 additions & 0 deletions
19
airbyte-cdk/python/airbyte_cdk/sources/declarative/schema/inline_schema_loader.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,19 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
from dataclasses import InitVar, dataclass | ||
from typing import Any, Dict, Mapping | ||
|
||
from airbyte_cdk.sources.declarative.schema.schema_loader import SchemaLoader | ||
|
||
|
||
@dataclass | ||
class InlineSchemaLoader(SchemaLoader): | ||
"""Describes a stream's schema""" | ||
|
||
schema: Dict[str, Any] | ||
options: InitVar[Mapping[str, Any]] | ||
|
||
def get_json_schema(self) -> Mapping[str, Any]: | ||
return self.schema |
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
19 changes: 19 additions & 0 deletions
19
airbyte-cdk/python/unit_tests/sources/declarative/schema/test_inline_schema_loader.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,19 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import pytest | ||
from airbyte_cdk.sources.declarative.schema import InlineSchemaLoader | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"test_name, input_schema, expected_schema", | ||
[ | ||
("schema", {"k": "string"}, {"k": "string"}), | ||
("empty_schema", {}, {}), | ||
], | ||
) | ||
def test_static_schema_loads(test_name, input_schema, expected_schema): | ||
schema_loader = InlineSchemaLoader(input_schema, {}) | ||
|
||
assert schema_loader.get_json_schema() == expected_schema |
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