-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5815658
commit 0b981ba
Showing
14 changed files
with
430 additions
and
55 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
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
Empty file.
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,32 @@ | ||
# imports | ||
import ibis | ||
|
||
from datetime import datetime | ||
|
||
# set extracted_at timestamp | ||
# note we don't use ibis.now() to ensure it's the same... | ||
# ...for all tables/rows on a given run | ||
extracted_at = datetime.utcnow().isoformat() | ||
|
||
|
||
# functions | ||
def add_extracted_at(t: ibis.Table) -> ibis.Table: | ||
"""Add extracted_at column to table""" | ||
|
||
# add extracted_at column and relocate it to the first position | ||
t = t.mutate(extracted_at=ibis.literal(extracted_at)).relocate("extracted_at") | ||
|
||
return t | ||
|
||
|
||
# data assets | ||
def penguins() -> ibis.Table: | ||
"""Extract penguins data""" | ||
|
||
# read in raw data | ||
penguins = ibis.examples.penguins.fetch() | ||
|
||
# add extracted_at column | ||
penguins = penguins.pipe(add_extracted_at) | ||
|
||
return penguins |
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,22 @@ | ||
# imports | ||
from icarus.config import PENGUINS_TABLE | ||
from icarus.catalog import Catalog | ||
from icarus.penguins.extract import ( | ||
penguins as extract_penguins, | ||
) | ||
from icarus.penguins.transform import penguins as transform_penguins | ||
|
||
|
||
# functions | ||
def main(): | ||
# instantiate catalog | ||
catalog = Catalog() | ||
|
||
# extract | ||
extract_penguins_t = extract_penguins() | ||
|
||
# transform | ||
transform_penguins_t = transform_penguins(extract_penguins_t) | ||
|
||
# load | ||
catalog.write_table(transform_penguins_t, PENGUINS_TABLE) |
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,33 @@ | ||
# imports | ||
import ibis | ||
import ibis.selectors as s | ||
|
||
|
||
# functions | ||
def preprocess(t: ibis.Table) -> ibis.Table: | ||
"""Common preprocessing steps""" | ||
|
||
# ensure unique records | ||
t = t.distinct(on=~s.c("extracted_at"), keep="first").order_by("extracted_at") | ||
|
||
return t | ||
|
||
|
||
def postprocess(t: ibis.Table) -> ibis.Table: | ||
"""Common postprocessing steps""" | ||
|
||
# ensure consistent column casing | ||
t = t.rename("snake_case") | ||
|
||
return t | ||
|
||
|
||
# data assets | ||
def penguins(t: ibis.Table) -> ibis.Table: | ||
"""Transform penguins data.""" | ||
|
||
def transform(t): | ||
return t | ||
|
||
penguins = t.pipe(preprocess).pipe(transform).pipe(postprocess) | ||
return penguins |
Oops, something went wrong.