Skip to content

Instantly share code, notes, and snippets.

@Stiivi
Last active March 19, 2017 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stiivi/dd2ed5bf6f3f63ef2e35255fa9468fe3 to your computer and use it in GitHub Desktop.
Save Stiivi/dd2ed5bf6f3f63ef2e35255fa9468fe3 to your computer and use it in GitHub Desktop.
Cubes non-intuitive data types
# The following data types were discovered in Cubes while type-annotating the source code.
# Sometimes it might seemed a good idea to permit people pass whatever they want, however opens
# way too many possibilities for unchecked errors.
#
# Type that can be passed as drilldown to the browser's `aggregate()` function:
#
_DrilldownType = Union[
Drilldown,
Dict[str, Union[Dimension, str]],
List[
Union[
str,
DrilldownItem,
Dimension,
Tuple[
Union[Dimension, str],
Union[Hierarchy, str],
Union[Level,str]
]
]
]
]
# distilled_hierarchies
#
_ = Dict[Tuple[str,Optional[str]],List[str]]
# Type that can be passed as rollup to the cell:
#
_ = Union[str, List[str], Dict[str,str]]
# Order types in browser's prepare_order():
_OrderType = Tuple[AttributeBase,str]
_OrderArgType = Union[str, Union[_OrderType, Tuple[str,str]]]
# Report return type:
_ = Dict[str, Union[AggregationResult, Facts, JSONType]]
# SQL Joins in JSON
#
_JoinKeyFreeType = Union[
Optional[str],
Tuple[str],
Tuple[Optional[str], str],
Tuple[Optional[str], Optional[str], str],
Mapping[str, str],
JoinKey,
]
_JoinFreeType = Union[
Tuple[_JoinKeyFreeType, _JoinKeyFreeType],
Tuple[_JoinKeyFreeType, _JoinKeyFreeType, str],
Tuple[_JoinKeyFreeType, _JoinKeyFreeType, str, str],
Mapping[str, str],
Join,
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment