-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from parkervg/feature/lazy-evaluation
`unpack_options()`, adding options argument to MapIngredient
- Loading branch information
Showing
14 changed files
with
217 additions
and
66 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Union, List, Set, Dict | ||
|
||
from ..utils import get_tablename_colname | ||
from ..db import Database | ||
|
||
|
||
def unpack_options( | ||
options: Union[List[str], str], aliases_to_tablenames: Dict[str, str], db: Database | ||
) -> Set[str]: | ||
unpacked_options = options | ||
if not isinstance(options, list): | ||
try: | ||
tablename, colname = get_tablename_colname(options) | ||
tablename = aliases_to_tablenames.get(tablename, tablename) | ||
# Optionally materialize a CTE | ||
if tablename in db.lazy_tables: | ||
unpacked_options = ( | ||
db.lazy_tables.pop(tablename).collect()[colname].unique().tolist() | ||
) | ||
else: | ||
unpacked_options = db.execute_to_list( | ||
f'SELECT DISTINCT "{colname}" FROM "{tablename}"' | ||
) | ||
except ValueError: | ||
unpacked_options = options.split(";") | ||
return set(unpacked_options) |
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
Oops, something went wrong.