Skip to content

Commit

Permalink
add: enable bigquery resources on open collective (#2077)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabolol authored Sep 5, 2024
1 parent 4774d4f commit 3684b6a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions warehouse/oso_dagster/assets/open_collective.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import dlt
from dagster import AssetExecutionContext, WeeklyPartitionsDefinition
from dlt.destinations.adapters import bigquery_adapter
from gql import Client, gql
from gql.transport.requests import RequestsHTTPTransport
from oso_dagster import constants
from oso_dagster.factories import dlt_factory, pydantic_to_dlt_nullable_columns
from oso_dagster.utils.secrets import secret_ref_arg
from pydantic import UUID4, BaseModel
Expand Down Expand Up @@ -270,13 +272,21 @@ def expenses(
"""

client = base_open_collective_client(personal_token)
yield dlt.resource(
resource = dlt.resource(
get_open_collective_expenses(context, client, "DEBIT"),
name="expenses",
columns=pydantic_to_dlt_nullable_columns(Transaction),
primary_key="id",
)

if constants.enable_bigquery:
bigquery_adapter(
resource,
partition="created_at",
)

yield resource


@dlt_factory(
key_prefix="open_collective",
Expand All @@ -303,9 +313,17 @@ def deposits(
"""

client = base_open_collective_client(personal_token)
yield dlt.resource(
resource = dlt.resource(
get_open_collective_expenses(context, client, "CREDIT"),
name="funds",
columns=pydantic_to_dlt_nullable_columns(Transaction),
primary_key="id",
)

if constants.enable_bigquery:
bigquery_adapter(
resource,
partition="created_at",
)

yield resource

0 comments on commit 3684b6a

Please sign in to comment.