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

πŸ› Source Fauna: fix bug during discover step #20275

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
- name: Fauna
sourceDefinitionId: 3825db3e-c94b-42ac-bd53-b5a9507ace2b
dockerRepository: airbyte/source-fauna
dockerImageTag: 0.1.0
dockerImageTag: 0.1.1
documentationUrl: https://docs.airbyte.com/integrations/sources/fauna
icon: fauna.svg
sourceType: database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4112,7 +4112,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-fauna:0.1.0"
- dockerImage: "airbyte/source-fauna:0.1.1"
spec:
documentationUrl: "https://github.com/fauna/airbyte/blob/source-fauna/docs/integrations/sources/fauna.md"
connectionSpecification:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-fauna/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_fauna ./source_fauna
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.name=airbyte/source-fauna
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ def discover(self, logger: AirbyteLogger, config: json) -> AirbyteCatalog:
type(source) is Ref
and source.collection() == Ref("collections")
# Index must have 2 values and no terms
and len(index["values"]) == 2
and len(index["terms"]) == 0
and ("values" in index and len(index["values"]) == 2)
and (("terms" in index and len(index["terms"]) == 0) or "terms" not in index)
# Index values must be ts and ref
and index["values"][0] == {"field": "ts"}
and index["values"][1] == {"field": "ref"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ def setup_database(source: SourceFauna):
}
),
)
# This index just *existing* used to crash the connector, because it has no
# terms or values.
source.client.query(
q.create_index(
{
"name": "breaks_things",
"source": q.collection("foo"),
}
),
)
print("Database is setup!")

# Store all the refs and ts of the documents we created, so that we can validate them
Expand Down Expand Up @@ -160,6 +170,28 @@ def setup_container():
raise


def run_discover_test(source: SourceFauna, logger):
# See `test_util.py` for these values
catalog = source.discover(logger, {
"secret": "secret",
"domain": "localhost",
"port": 9000,
"scheme": "http",
"collection": {
"page_size": 64,
"deletions": {
"deletion_mode": "ignore",
}
}
})
assert len(catalog.streams) == 1
stream = catalog.streams[0]
assert stream.name == "foo"
assert stream.supported_sync_modes == [SyncMode.full_refresh, SyncMode.incremental]
assert stream.source_defined_cursor is True
assert stream.default_cursor_field == ["ts"]


def run_add_removes_test(source: SourceFauna, logger, stream: ConfiguredAirbyteStream):
source._setup_client(FullConfig.localhost())
source.client.query(q.create(ref(105, "foo"), {"data": {"a": 10}}))
Expand Down Expand Up @@ -477,6 +509,7 @@ def run_updates_test(db_data, source: SourceFauna, logger, catalog: ConfiguredAi

def run_test(db_data, source: SourceFauna):
logger = mock_logger()
run_discover_test(source, logger)
stream = ConfiguredAirbyteStream(
stream=AirbyteStream(name="foo", json_schema={}, supported_sync_modes=[SyncMode.incremental, SyncMode.full_refresh]),
sync_mode=SyncMode.incremental,
Expand All @@ -489,7 +522,7 @@ def run_test(db_data, source: SourceFauna):
run_general_remove_test(source, logger)


def test_incremental_reads():
def test_database():
container, db_data, source = setup_container()

try:
Expand Down
7 changes: 4 additions & 3 deletions docs/integrations/sources/fauna.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ FQL [`Select`](https://docs.fauna.com/fauna/current/api/fql/functions/select) is

## Changelog

| Version | Date | Pull Request | Subject |
| ------- | ---------- | -------------------------------------------------------- | ---------------- |
| 0.1.0 | 2022-11-17 | [15274](https://github.com/airbytehq/airbyte/pull/15274) | Add Fauna Source |
| Version | Date | Pull Request | Subject |
| ------- | ---------- | -------------------------------------------------------- | ------------------------------- |
| 0.1.1 | 2022-12-12 | [20275](https://github.com/airbytehq/airbyte/pull/20275) | Fix index lookup with no values |
| 0.1.0 | 2022-11-17 | [15274](https://github.com/airbytehq/airbyte/pull/15274) | Add Fauna Source |