Skip to content

Commit

Permalink
[non-forked] 🐛 Source Fauna: fix bug during discover step (#23583)
Browse files Browse the repository at this point in the history
* Fix a bug where no terms or no values would crash discover()

* Add a test to validate discover() against a real database

* Cleanup conditional, and allow an index without terms as well as an index with no terms

* Bump connector version, and add PR to changelog

* Run ./gradlew :airbyte-config:init:processResources

* Automated Change

---------

Co-authored-by: Neil Macneale V <neil.macneale.v@gmail.com>
Co-authored-by: natalyjazzviolin <natalyjazzviolin@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 28, 2023
1 parent 1a22813 commit a753554
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,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 @@ -4111,7 +4111,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
2 changes: 1 addition & 1 deletion connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
| **Facebook Marketing** | <img alt="Facebook Marketing icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/facebook.svg" height="30" height="30"/> | Source | airbyte/source-facebook-marketing:0.2.85 | generally_available | [link](https://docs.airbyte.com/integrations/sources/facebook-marketing) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-facebook-marketing) | <small>`e7778cfc-e97c-4458-9ecb-b4f2bba8946c`</small> |
| **Facebook Pages** | <img alt="Facebook Pages icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/facebook.svg" height="30" height="30"/> | Source | airbyte/source-facebook-pages:0.2.3 | beta | [link](https://docs.airbyte.com/integrations/sources/facebook-pages) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-facebook-pages) | <small>`010eb12f-837b-4685-892d-0a39f76a98f5`</small> |
| **Fastbill** | <img alt="Fastbill icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/fastbill.svg" height="30" height="30"/> | Source | airbyte/source-fastbill:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/fastbill) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-fastbill) | <small>`eb3e9c1c-0467-4eb7-a172-5265e04ccd0a`</small> |
| **Fauna** | <img alt="Fauna icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/fauna.svg" height="30" height="30"/> | Source | airbyte/source-fauna:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/fauna) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-fauna) | <small>`3825db3e-c94b-42ac-bd53-b5a9507ace2b`</small> |
| **Fauna** | <img alt="Fauna icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/fauna.svg" height="30" height="30"/> | Source | airbyte/source-fauna:0.1.1 | alpha | [link](https://docs.airbyte.com/integrations/sources/fauna) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-fauna) | <small>`3825db3e-c94b-42ac-bd53-b5a9507ace2b`</small> |
| **File (CSV, JSON, Excel, Feather, Parquet)** | <img alt="File (CSV, JSON, Excel, Feather, Parquet) icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/file.svg" height="30" height="30"/> | Source | airbyte/source-file:0.2.33 | generally_available | [link](https://docs.airbyte.com/integrations/sources/file) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-file) | <small>`778daa7c-feaf-4db6-96f3-70fd645acc77`</small> |
| **Firebolt** | <img alt="Firebolt icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/firebolt.svg" height="30" height="30"/> | Source | airbyte/source-firebolt:0.2.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/firebolt) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-firebolt) | <small>`6f2ac653-8623-43c4-8950-19218c7caf3d`</small> |
| **Flexport** | x | Source | airbyte/source-flexport:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/flexport) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-flexport) | <small>`f95337f1-2ad1-4baf-922f-2ca9152de630`</small> |
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 |

0 comments on commit a753554

Please sign in to comment.