Skip to content

Commit

Permalink
Update materialize fivetran assets section
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Nov 27, 2024
1 parent 7e0bdce commit e67667f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
22 changes: 15 additions & 7 deletions docs/content/integrations/fivetran/fivetran.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ defs = dg.Definitions(
)
```


### Sync and materialize Fivetran assets

You can use Dagster to sync Fivetran connectors and materialize Fivetran connector tables.
You can use Dagster to sync Fivetran connectors and materialize Fivetran connector tables. You can use the <PyObject module="dagster_fivetran" method="fivetran_assets" /> decorator to create the assets definition for a given connector, or the <PyObject module="dagster_fivetran" method="build_fivetran_assets_definitions" /> factory to create all assets definitions for your Fivetran workspace.

```python file=/integrations/fivetran/sync-and-materialize-fivetran-assets.py
from dagster_fivetran import FivetranWorkspace, fivetran_assets
from dagster_fivetran import (
FivetranWorkspace,
build_fivetran_assets_definitions,
fivetran_assets,
)

import dagster as dg

Expand All @@ -66,6 +69,7 @@ fivetran_workspace = FivetranWorkspace(
)


# Creating assets definition for a given connector using the `@fivetran_assets` decorator
@fivetran_assets(
connector_id="fivetran_connector_id",
name="fivetran_connector_id",
Expand All @@ -78,8 +82,12 @@ def fivetran_connector_assets(
yield from fivetran.sync_and_poll(context=context)


# Alternatively, creating all assets definitions for the Fivetran workspace
# using the `build_fivetran_assets_definitions` factory
all_fivetran_assets = build_fivetran_assets_definitions(fivetran_workspace)

defs = dg.Definitions(
assets=[fivetran_connector_assets],
assets=[*all_fivetran_assets],
resources={"fivetran": fivetran_workspace},
)
```
Expand Down Expand Up @@ -142,12 +150,12 @@ def fivetran_connector_assets(

# Alternatively, when creating all assets definitions for the Fivetran workspace
# using the `build_fivetran_assets_definitions` factory
fivetran_assets = build_fivetran_assets_definitions(
all_fivetran_assets = build_fivetran_assets_definitions(
fivetran_workspace, dagster_fivetran_translator=MyCustomFivetranTranslator()
)

defs = dg.Definitions(
assets=[*fivetran_assets], resources={"fivetran": fivetran_workspace}
assets=[*all_fivetran_assets], resources={"fivetran": fivetran_workspace}
)
```

Expand Down Expand Up @@ -184,4 +192,4 @@ defs = dg.Definitions(
"sales_fivetran": sales_fivetran_workspace,
},
)
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def fivetran_connector_assets(

# Alternatively, when creating all assets definitions for the Fivetran workspace
# using the `build_fivetran_assets_definitions` factory
fivetran_assets = build_fivetran_assets_definitions(
all_fivetran_assets = build_fivetran_assets_definitions(
fivetran_workspace, dagster_fivetran_translator=MyCustomFivetranTranslator()
)

defs = dg.Definitions(
assets=[*fivetran_assets], resources={"fivetran": fivetran_workspace}
assets=[*all_fivetran_assets], resources={"fivetran": fivetran_workspace}
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from dagster_fivetran import FivetranWorkspace, fivetran_assets
from dagster_fivetran import (
FivetranWorkspace,
build_fivetran_assets_definitions,
fivetran_assets,
)

import dagster as dg

Expand All @@ -9,6 +13,7 @@
)


# Creating assets definition for a given connector using the `@fivetran_assets` decorator
@fivetran_assets(
connector_id="fivetran_connector_id",
name="fivetran_connector_id",
Expand All @@ -21,7 +26,11 @@ def fivetran_connector_assets(
yield from fivetran.sync_and_poll(context=context)


# Alternatively, creating all assets definitions for the Fivetran workspace
# using the `build_fivetran_assets_definitions` factory
all_fivetran_assets = build_fivetran_assets_definitions(fivetran_workspace)

defs = dg.Definitions(
assets=[fivetran_connector_assets],
assets=[*all_fivetran_assets],
resources={"fivetran": fivetran_workspace},
)

0 comments on commit e67667f

Please sign in to comment.