mstrio.modeling.expression package¶
Submodules¶
mstrio.modeling.expression.dynamic_date_time module¶
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentMonthlyByDay(day: int)¶
Bases:
DateAdjustment
Adjustment at the month level by day
- day¶
day of month (1 - 31)
- Type:
int
- day: int¶
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentMonthlyByDayOfWeek(week_ordinal: int, day_of_week: DayOfWeek)¶
Bases:
DateAdjustment
Adjustment at the month level by day of week
- week_ordinal¶
number indicating 1st, 2nd, 3rd, etc.
- Type:
int
- day_of_week¶
day of week, value of DayOfWeek enum
- week_ordinal: int¶
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentMonthlyByReverseCount(days: int, months: int)¶
Bases:
DateAdjustment
Adjustment at the month level by reverse count
- days¶
number of days to reverse count
- Type:
int
- months¶
number of months to reverse count
- Type:
int
- days: int¶
- months: int¶
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentNone¶
Bases:
DateAdjustment
Indicate that there is no further adjustments
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentQuarterlyByDay(day: int)¶
Bases:
DateAdjustment
Adjustment at the quarter level by day
- day¶
day in the quarter
- Type:
int
- day: int¶
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentQuarterlyByDayOfWeek(month_ordinal: int, week_ordinal: int, day_of_week: DayOfWeek)¶
Bases:
DateAdjustment
Adjustment at the quarter level by day of week
- month_ordinal¶
number indicating 1st, 2nd, or 3rd month in the quarter
- Type:
int
- week_ordinal¶
number indicating 1st, 2nd, 3rd, etc.
- Type:
int
- day_of_week¶
day of week, value of DayOfWeek enum
- month_ordinal: int¶
- week_ordinal: int¶
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentQuarterlyByReverseCount(days: int)¶
Bases:
DateAdjustment
Adjustment at the quarter level by reverse count
- days¶
number of days to reverse count
- Type:
int
- days: int¶
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentWeeklyByDayOfWeek(day_of_week: DayOfWeek)¶
Bases:
DateAdjustment
Adjustment at the week level by day of week
- day_of_week¶
day of week, value of DayOfWeek enum
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentYearlyByDate(month: int, day: int)¶
Bases:
DateAdjustment
Adjustment at the year level by date
- month¶
Month of the year (1 - 12)
- Type:
int
- day¶
Day of month (1 - 31)
- Type:
int
- day: int¶
- month: int¶
- class mstrio.modeling.expression.dynamic_date_time.AdjustmentYearlyByDayOfWeek(month: int, week_ordinal: int, day_of_week: DayOfWeek)¶
Bases:
DateAdjustment
Adjustment at the year level by day of week
- month¶
Month of the year (1 - 12)
- Type:
int
- week_ordinal¶
Number indicating 1st, 2nd, 3rd, etc.
- Type:
int
- day_of_week¶
day of week, value of DayOfWeek enum
- month: int¶
- week_ordinal: int¶
- class mstrio.modeling.expression.dynamic_date_time.DateAdjustment¶
Bases:
Dictable
Base class for date adjustment objects
- class mstrio.modeling.expression.dynamic_date_time.DateMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating mode of date
- DYNAMIC = 'dynamic'¶
- STATIC = 'static'¶
- class mstrio.modeling.expression.dynamic_date_time.DayOfWeek(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
Enumeration used to indicate day of week
- FRIDAY = 5¶
- MONDAY = 1¶
- SATURDAY = 6¶
- SUNDAY = 0¶
- THURSDAY = 4¶
- TUESDAY = 2¶
- WEDNESDAY = 3¶
- class mstrio.modeling.expression.dynamic_date_time.DynamicDateTimeStructure(type: DynamicDateTimeType, date: mstrio.modeling.expression.dynamic_date_time.VersatileDate | None = None, time: mstrio.modeling.expression.dynamic_date_time.VersatileTime | None = None)¶
Bases:
Dictable
Object that represents a date/time. It can be date-only, or time-only, or date-time. The date part and the time part can be dynamic or static independently. Typically, this object is used when at least one of the two parts is dynamic. Although it’s capable of describing a static date/time, the much simpler Variant is preferable in that case.
- type¶
represents what part is being used, either date, time or date/time
- date¶
Object that represents either a dynamic date or a static date
- time¶
Object that represents either a dynamic time or a static time
- date: mstrio.modeling.expression.dynamic_date_time.VersatileDate | None = None¶
- time: mstrio.modeling.expression.dynamic_date_time.VersatileTime | None = None¶
- type: DynamicDateTimeType¶
- class mstrio.modeling.expression.dynamic_date_time.DynamicDateTimeType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating type of dynamic date time object
- DATE = 'date'¶
- DATE_TIME = 'date_time'¶
- TIME = 'time'¶
- class mstrio.modeling.expression.dynamic_date_time.DynamicVersatileDate(day_offset: int, month_offset: int, adjustment: DateAdjustment = AdjustmentNone(), exclude_weekends: bool | None = None)¶
Bases:
VersatileDate
Object that represents a dynamic date. Its various settings define a function that will resolve to a date using the current date as the input.
- day_offset¶
The day offset
- Type:
int
- month_offset¶
The month offset
- Type:
int
- exclude_weekends¶
Whether weekend days should be excluded during calculation, default: False
- Type:
bool | None
- adjustment¶
adjustment of a date, instance of one of classes inheriting from DateAdjustment class
- adjustment: DateAdjustment = AdjustmentNone()¶
- day_offset: int¶
- exclude_weekends: bool | None = None¶
- classmethod from_dict(source: dict, connection: Connection | None = None, to_snake_case=True) DynamicVersatileDate ¶
Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of an object that should be created.
source (Dict[str, Any]) – A dictionary from which an object will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
An object of type T.
- Return type:
T
- month_offset: int¶
- to_dict(camel_case: bool = True) dict ¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- class mstrio.modeling.expression.dynamic_date_time.HourMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating mode of hour
- DYNAMIC = 'dynamic'¶
- STATIC = 'static'¶
- class mstrio.modeling.expression.dynamic_date_time.MinuteAndSecondMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating mode of minute and second
- DYNAMIC = 'dynamic'¶
- STATIC = 'static'¶
- class mstrio.modeling.expression.dynamic_date_time.StaticVersatileDate(value: str)¶
Bases:
VersatileDate
Object that represents a static date
- value¶
ISO 8601 string of the date component
- Type:
str
- to_dict(camel_case: bool = True) dict ¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- value: str¶
- class mstrio.modeling.expression.dynamic_date_time.VersatileDate¶
Bases:
Dictable
Base class for classes representing dynamic or static date objects
- static dispatch(source, connection: Connection | None = None) type['VersatileDate'] ¶
- Returns an appropriate VersatileDate type object from the
provided source
- Parameters:
source – object that specifies the VersatileDate object that will be returned
connection (optional) – MicroStrategy connection object returned
connection.Connection() (by) –
- class mstrio.modeling.expression.dynamic_date_time.VersatileTime(hour_mode: HourMode, minute_and_second_mode: MinuteAndSecondMode, hour: int | None = None, hour_offset: int | None = None, minute: int | None = None, minute_offset: int | None = None, second: int | None = None, second_offset: int | None = None)¶
Bases:
Dictable
Object that represents either a dynamic time or a static time
- hour_mode¶
The hour component (0-23). Used when the hour is static.
- hour_offset¶
The offset from the current hour. Used when the hour is dynamic.
- Type:
int | None
- minute_and_second_mode¶
The minute component (0-59). Used when the minute is static.
- minute_offset¶
The offset from the current minute. Used when the minute is dynamic.
- Type:
int | None
- second¶
The second component (0-59). Used when the second is static.
- Type:
int | None
- second_offset¶
The offset from the current second. Used when the second is dynamic.
- Type:
int | None
- hour: int | None = None¶
- hour_offset: int | None = None¶
- minute: int | None = None¶
- minute_and_second_mode: MinuteAndSecondMode¶
- minute_offset: int | None = None¶
- second: int | None = None¶
- second_offset: int | None = None¶
mstrio.modeling.expression.enums module¶
- class mstrio.modeling.expression.enums.DependenceType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating the dependence type of expression node
- DEFAULT = 'default'¶
- DEPENDENT = 'dependent'¶
- INDEPENDENT = 'independent'¶
- class mstrio.modeling.expression.enums.DimtyType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating the dimty type of expression node
- BREAK_BY = 'break_by'¶
- CONTINUATION = 'continuation'¶
- EMBEDDED = 'embedded'¶
- EXCLUSIVE_CONTINUATION = 'exclusive_continuation'¶
- NONE = 'none'¶
- OUTPUT_LEVEL = 'output_level'¶
- PARAMETER = 'parameter'¶
- UNSPECIFIED = 'unspecified'¶
- class mstrio.modeling.expression.enums.ExpressionFormat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
“Expression format to be fetched from server, it might be tree or token: - tree: tree data structure fully defining the expression. This format can be used if you want to examine and modify the expression programmatically. - tokens: list of parsed tokens. This format can be used if you want to examine and modify the expression using the parser component. Note that generating tokens requires additional time.
- TOKENS = 'tokens'¶
- TREE = 'tree'¶
- class mstrio.modeling.expression.enums.ExpressionType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating the expression type of expression node
- AGG_METRIC = 'agg_metric'¶
- BANDING = 'banding'¶
- CANCELED_PROMPT = 'canceled_prompt'¶
- CSI_DELETE = 'csi_delete'¶
- CSI_GROUP = 'csi_group'¶
- CSI_INSERT = 'csi_insert'¶
- CSI_UPDATE = 'csi_update'¶
- DYNAMIC = 'dynamic'¶
- ELEMENT_LIST = 'element_list'¶
- ELEMENT_SINGLE = 'element_single'¶
- FILTER_ALL_ATTRIBUTE_QUAL = 'filter_all_attribute_qual'¶
- FILTER_ATTRIBUTE_DESC_QUAL = 'filter_attribute_desc_qual'¶
- FILTER_ATTRIBUTE_ID_QUAL = 'filter_attribute_id_qual'¶
- FILTER_BRANCH_QUAL = 'filter_branch_qual'¶
- FILTER_EMBED_QUAL = 'filter_embed_qual'¶
- FILTER_JOINT_FORM_QUAL = 'filter_joint_form_qual'¶
- FILTER_JOINT_LIST_FORM_QUAL = 'filter_joint_list_form_qual'¶
- FILTER_JOINT_LIST_QUAL = 'filter_joint_list_qual'¶
- FILTER_LIST_FORM_QUAL = 'filter_list_form_qual'¶
- FILTER_LIST_QUAL = 'filter_list_qual'¶
- FILTER_METRIC_EXPRESSION = 'filter_metric_expression'¶
- FILTER_MULTI_BASE_FORM_QUAL = 'filter_multi_base_form_qual'¶
- FILTER_MULTI_METRIC_QUAL = 'filter_multi_metric_qual'¶
- FILTER_RELATIONSHIP_QUAL = 'filter_relationship_qual'¶
- FILTER_REPORT_QUAL = 'filter_report_qual'¶
- FILTER_SINGLE_BASE_FORM_EXPRESSION = 'filter_single_base_form_expression'¶
- FILTER_SINGLE_BASE_FORM_QUAL = 'filter_single_base_form_qual'¶
- FILTER_SINGLE_METRIC_QUAL = 'filter_single_metric_qual'¶
- FORM_OF_THIS_ATTRIBUTE = 'form_of_this_attribute'¶
- GENERIC = 'generic'¶
- MDX_SAP_VARIABLE = 'mdx_sap_variable'¶
- SQL_QUERY_QUAL = 'sql_query_qual'¶
- STATIC = 'static'¶
- class mstrio.modeling.expression.enums.Function(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant used to specify the function used for calculation in expression nodes
- ABS = 'abs'¶
- ADD = 'add'¶
- ADD_DAYS = 'add_days'¶
- ADD_MONTHS = 'add_months'¶
- AMPERSAND = 'ampersand'¶
- ANCESTORS = 'ancestors'¶
- AND = 'and'¶
- APPLY_AGGREGATION = 'apply_aggregation'¶
- APPLY_COMPARISON = 'apply_comparison'¶
- APPLY_CS_SECURITY_FILTER = 'apply_cs_security_filter'¶
- APPLY_LOGIC = 'apply_logic'¶
- APPLY_OPTIONAL = 'apply_optional'¶
- APPLY_RELATIVE = 'apply_relative'¶
- APPLY_SIMPLE = 'apply_simple'¶
- AVERAGE = 'average'¶
- AVG = 'avg'¶
- BANDING = 'banding'¶
- BANDING_C = 'banding_c'¶
- BANDING_M = 'banding_m'¶
- BANDING_P = 'banding_p'¶
- BAND_NAMES = 'band_names'¶
- BEGINS_WITH = 'begins_with'¶
- BETWEEN = 'between'¶
- BETWEEN_ENHANCED = 'between_enhanced'¶
- BIT_AND = 'bit_and'¶
- BIT_LEFT_SHIFT = 'bit_left_shift'¶
- BIT_NOT = 'bit_not'¶
- BIT_OR = 'bit_or'¶
- BIT_RIGHT_SHIFT = 'bit_right_shift'¶
- BIT_XOR = 'bit_xor'¶
- CASE = 'case'¶
- CASE_V = 'case_v'¶
- CHILDREN = 'children'¶
- COALESCE = 'coalesce'¶
- CONCAT = 'concat'¶
- CONCAT_AGG = 'concat_agg'¶
- CONCAT_NO_BLANK = 'concat_no_blank'¶
- CONTAINS = 'contains'¶
- COUNT = 'count'¶
- CURRENT_DATE = 'current_date'¶
- CURRENT_DATE_TIME = 'current_date_time'¶
- CURRENT_TIME = 'current_time'¶
- CUSTOM = 'custom'¶
- DATE = 'date'¶
- DATE_DIFF = 'date_diff'¶
- DAYS_BETWEEN = 'days_between'¶
- DAY_OF_MONTH = 'day_of_month'¶
- DAY_OF_WEEK = 'day_of_week'¶
- DAY_OF_YEAR = 'day_of_year'¶
- DESCENDANTS = 'descendants'¶
- DIVIDE = 'divide'¶
- ENDS_WITH = 'ends_with'¶
- EQUALS = 'equals'¶
- EQUAL_ENHANCED = 'equal_enhanced'¶
- EXCEPT = 'except'¶
- EXP_WGH_MOVING_AVG = 'exp_wgh_moving_avg'¶
- EXP_WGH_RUNNING_AVG = 'exp_wgh_running_avg'¶
- FIRST = 'first'¶
- FIRST_IN_RANGE = 'first_in_range'¶
- FISCAL_MONTH = 'fiscal_month'¶
- FISCAL_QUARTER = 'fiscal_quarter'¶
- FISCAL_WEEK = 'fiscal_week'¶
- FISCAL_YEAR = 'fiscal_year'¶
- GEOMEAN = 'geomean'¶
- GET_EXTRA_OUTPUT = 'get_extra_output'¶
- GREATER = 'greater'¶
- GREATER_EQUAL = 'greater_equal'¶
- GREATER_EQUAL_ENHANCED = 'greater_equal_enhanced'¶
- GREATEST = 'greatest'¶
- HISTOGRAM_MEDIAN = 'histogram_median'¶
- HOUR = 'hour'¶
- IF = 'if'¶
- IF_BY_DIMTY = 'if_by_dimty'¶
- IN = 'in'¶
- INIT_CAP = 'init_cap'¶
- INTERSECT = 'intersect'¶
- INTERSECT_IN = 'intersect_in'¶
- IS_NOT_NULL = 'is_not_null'¶
- IS_NULL = 'is_null'¶
- LAG = 'lag'¶
- LAST = 'last'¶
- LAST_IN_RANGE = 'last_in_range'¶
- LEAD = 'lead'¶
- LEAST = 'least'¶
- LEFT_STR = 'left_str'¶
- LENGTH = 'length'¶
- LESS = 'less'¶
- LESS_EQUAL = 'less_equal'¶
- LESS_EQUAL_ENHANCED = 'less_equal_enhanced'¶
- LIKE = 'like'¶
- LOWER = 'lower'¶
- L_TRIM = 'l_trim'¶
- MAX = 'max'¶
- MEDIAN = 'median'¶
- MILLI_SECOND = 'milli_second'¶
- MIN = 'min'¶
- MINUS = 'minus'¶
- MINUTE = 'minute'¶
- MODE = 'mode'¶
- MONTH = 'month'¶
- MONTHS_BETWEEN = 'months_between'¶
- MONTH_END_DATE = 'month_end_date'¶
- MONTH_START_DATE = 'month_start_date'¶
- MOVING_AVG = 'moving_avg'¶
- MOVING_COUNT = 'moving_count'¶
- MOVING_DIFFERENCE = 'moving_difference'¶
- MOVING_MAX = 'moving_max'¶
- MOVING_MIN = 'moving_min'¶
- MOVING_STDEV = 'moving_stdev'¶
- MOVING_STDEV_P = 'moving_stdev_p'¶
- MOVING_SUM = 'moving_sum'¶
- MULTIPLY = 'multiply'¶
- NOT = 'not'¶
- NOT_BEGINS_WITH = 'not_begins_with'¶
- NOT_BETWEEN = 'not_between'¶
- NOT_BETWEEN_ENHANCED = 'not_between_enhanced'¶
- NOT_CONTAINS = 'not_contains'¶
- NOT_ENDS_WITH = 'not_ends_with'¶
- NOT_EQUAL = 'not_equal'¶
- NOT_EQUAL_ENHANCED = 'not_equal_enhanced'¶
- NOT_IN = 'not_in'¶
- NOT_LIKE = 'not_like'¶
- NULL_TO_EMPTY = 'null_to_empty'¶
- NULL_TO_ZERO = 'null_to_zero'¶
- N_TILE = 'n_tile'¶
- N_TILE_S = 'n_tile_s'¶
- N_TILE_VS = 'n_tile_vs'¶
- OLAP_AVG = 'olap_avg'¶
- OLAP_COUNT = 'olap_count'¶
- OLAP_MAX = 'olap_max'¶
- OLAP_MIN = 'olap_min'¶
- OLAP_RANK = 'olap_rank'¶
- OLAP_SUM = 'olap_sum'¶
- OR = 'or'¶
- ORDINAL_RANK = 'ordinal_rank'¶
- PARENTS = 'parents'¶
- PERCENTILE = 'percentile'¶
- PERCENT_RANK = 'percent_rank'¶
- PERCENT_RANK_RELATIVE = 'percent_rank_relative'¶
- PLUS = 'plus'¶
- POSITION = 'position'¶
- PRODUCT = 'product'¶
- QUARTER = 'quarter'¶
- QUARTER_START_DATE = 'quarter_start_date'¶
- RANK = 'rank'¶
- REPEAT = 'repeat'¶
- RIGHT_STR = 'right_str'¶
- RUNNING_AVG = 'running_avg'¶
- RUNNING_COUNT = 'running_count'¶
- RUNNING_MAX = 'running_max'¶
- RUNNING_MIN = 'running_min'¶
- RUNNING_STDEV = 'running_stdev'¶
- RUNNING_STDEV_P = 'running_stdev_p'¶
- RUNNING_SUM = 'running_sum'¶
- R_TRIM = 'r_trim'¶
- SEARCH = 'search'¶
- SECOND = 'second'¶
- STDEV = 'stdev'¶
- STDEV_P = 'stdev_p'¶
- STR_BEGINS_WITH = 'str_begins_with'¶
- STR_CHAR = 'str_char'¶
- STR_ENDS_WITH = 'str_ends_with'¶
- STR_LAST_POSITION = 'str_last_position'¶
- STR_MATCH = 'str_match'¶
- STR_REPEAT = 'str_repeat'¶
- STR_REPLACE = 'str_replace'¶
- STR_SPLIT = 'str_split'¶
- STR_TITLE_CAP = 'str_title_cap'¶
- SUB_STR = 'sub_str'¶
- SUM = 'sum'¶
- THIRD_PARTY = 'third_party'¶
- TIMES = 'times'¶
- TO_DATE_TIME = 'to_date_time'¶
- TO_NUMBER = 'to_number'¶
- TO_STRING = 'to_string'¶
- TRIM = 'trim'¶
- TUPLE = 'tuple'¶
- UCASE = 'ucase'¶
- UNARY_MINUS = 'unary_minus'¶
- UNION = 'union'¶
- VALUE_SEGMENT = 'value_segment'¶
- VAR = 'var'¶
- VAR_P = 'var_p'¶
- WEEK = 'week'¶
- WEEK_START_DATE = 'week_start_date'¶
- WEIGHT_CORR = 'weight_corr'¶
- WEIGHT_COV = 'weight_cov'¶
- WEIGHT_MEAN_AVE = 'weight_mean_ave'¶
- WEIGHT_STD_P = 'weight_std_p'¶
- YEAR = 'year'¶
- YEAR_END_DATE = 'year_end_date'¶
- YEAR_START_DATE = 'year_start_date'¶
- ZERO_TO_NULL = 'zero_to_null'¶
- class mstrio.modeling.expression.enums.IsIndependent(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
Flag that indicates whether a node will be evaluated independently of other parts of the larger expression
- NO = 0¶
- YES = 1¶
- class mstrio.modeling.expression.enums.NodeType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating the type of node within the expression tree
- COLUMN_REFERENCE = 'column_reference'¶
- CONSTANT = 'constant'¶
- DYNAMIC_DATE_TIME = 'dynamic_date_time'¶
- FORM_SHORTCUT = 'form_shortcut'¶
- OBJECT_REFERENCE = 'object_reference'¶
- OPERATOR = 'operator'¶
- PREDICATE_BANDING_COUNT = 'predicate_banding_count'¶
- PREDICATE_BANDING_DISTINCT = 'predicate_banding_distinct'¶
- PREDICATE_BANDING_POINTS = 'predicate_banding_points'¶
- PREDICATE_BANDING_SIZE = 'predicate_banding_size'¶
- PREDICATE_CUSTOM = 'predicate_custom'¶
- PREDICATE_ELEMENT_LIST = 'predicate_element_list'¶
- PREDICATE_FILTER_QUALIFICATION = 'predicate_filter_qualification'¶
- PREDICATE_FORM_QUALIFICATION = 'predicate_form_qualification'¶
- PREDICATE_JOINT_ELEMENT_LIST = 'predicate_joint_element_list'¶
- PREDICATE_METRIC_QUALIFICATION = 'predicate_metric_qualification'¶
- PREDICATE_PROMPT_QUALIFICATION = 'predicate_prompt_qualification'¶
- PREDICATE_RELATIONSHIP = 'predicate_relationship'¶
- PREDICATE_REPORT_QUALIFICATION = 'predicate_report_qualification'¶
- RELATIONSHIP = 'relationship'¶
mstrio.modeling.expression.expression module¶
- class mstrio.modeling.expression.expression.Expression(text: str | None = None, tokens: list[mstrio.modeling.expression.expression.Token] | None = None, tree: mstrio.modeling.expression.expression.ExpressionNode | None = None)¶
Bases:
Dictable
Class representation of Expression.
A generic specification for a calculation stored within a metadata object. The expression is represented as a tree over nodes. Most internal nodes (called operator nodes) are defined by applying a function to the operator’s child nodes.
Usually an expression must be non-empty. But in a few cases, most notably a filter expression it is valid for an expression to contain no nodes at all. An expression is empty if and only if it does not have a tree property.
Alternatively the client may prefer to handle an expression as a list of tokens. Each token represents part of the raw text of the expression, in some cases annotated with additional information.
- text¶
Read only. Human-readable description of the expression. It is generated from the current specification of the expression.
- Type:
str | None
- tokens¶
Optional list, used if the expression is to be presented as a stream of tokens.
- Type:
list[mstrio.modeling.expression.expression.Token] | None
- tree¶
Representation of an expression as a tree of nodes, instance of one of classes inheriting from ExpressionNode class
- Type:
- text: str | None = None¶
- tokens: list[mstrio.modeling.expression.expression.Token] | None = None¶
- tree: mstrio.modeling.expression.expression.ExpressionNode | None = None¶
- class mstrio.modeling.expression.expression.ExpressionNode(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None)¶
Bases:
Dictable
Base class representing a node of an expression tree.
- dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None¶
- dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None¶
- static dispatch(source, connection: Optional[Connection] = None) type['ExpressionNode'] ¶
Method dispatching node data to appropriate class that represents this type of node.
- expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None¶
- to_dict(camel_case: bool = True) dict ¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- class mstrio.modeling.expression.expression.Token(value: str, type: mstrio.modeling.expression.expression.Token.Type | None = None, target: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, attribute_form: str | None = None, level: mstrio.modeling.expression.expression.Token.Level | None = None, state: mstrio.modeling.expression.expression.Token.State | None = None)¶
Bases:
Dictable
Class representation of a single tokens of an expression.
- type¶
Enumeration constant that classifies the text within this token
- Type:
- value¶
The raw text represented by a token
- Type:
str
- target¶
If the token represents an object, provide information about the object
- Type:
- level¶
Describe the amount of processing performed on this parser token
- Type:
- state¶
Whether token is in an error or not
- Type:
- attribute_form¶
If the token represents an attribute form in the context of an object (say City@DESC) then provide attribute form id
- Type:
str | None
- class Level(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant describing the amount of processing performed on a parser token
- CLIENT = 'client'¶
- LEXED = 'lexed'¶
- PARSED = 'parsed'¶
- RESOLVED = 'resolved'¶
- class State(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant describing whether token in an error or not
- ERROR = 'error'¶
- INITIAL = 'initial'¶
- OKAY = 'okay'¶
- class Type(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant that classifies the text within a token
- BOOLEAN = 'boolean'¶
- CHARACTER = 'character'¶
- COLUMN_REFERENCE = 'column_reference'¶
- DATE_TIME = 'date_time'¶
- ELEMENTS = 'elements'¶
- EMPTY = 'empty'¶
- END_OF_TEXT = 'end_of_text'¶
- ERROR = 'error'¶
- FLOAT = 'float'¶
- FUNCTION = 'function'¶
- GUID = 'guid'¶
- IDENTIFIER = 'identifier'¶
- INTEGER = 'integer'¶
- KEYWORD = 'keyword'¶
- LITERAL = 'literal'¶
- OBJECT_AT_FORM = 'object_at_form'¶
- OBJECT_REFERENCE = 'object_reference'¶
- OTHER = 'other'¶
- STRING_LITERAL = 'string_literal'¶
- UNKNOWN = 'unknown'¶
- attribute_form: str | None = None¶
- classmethod from_dict(source: dict, connection: Optional[Connection] = None, to_snake_case: bool = True)¶
Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of an object that should be created.
source (Dict[str, Any]) – A dictionary from which an object will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
An object of type T.
- Return type:
T
- level: mstrio.modeling.expression.expression.Token.Level | None = None¶
- state: mstrio.modeling.expression.expression.Token.State | None = None¶
- target: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- to_dict(camel_case=True) dict ¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- type: mstrio.modeling.expression.expression.Token.Type | None = None¶
- value: str¶
- mstrio.modeling.expression.expression.list_functions(connection: Connection, name: str | None = None, to_dictionary: bool = False, search_pattern: mstrio.object_management.search_enums.SearchPattern | int = SearchPattern.CONTAINS, project_id: str | None = None, project_name: str | None = None, limit: int | None = None, **filters) list['SchemaObjectReference'] | list[dict] ¶
Get list of SchemaObjectReference objects or dicts representing functions. Optionally filter functions by specifying ‘name’.
When attribute is: function for Operator node is set to Function.CUSTOM or Function.THIRD_PARTY, custom_function attribute is required. This function give list of SchemaObjectReference object that can be used as values for custom_function.
Optionally use to_dictionary to choose output format.
- Wildcards available for ‘name’:
? - any character * - 0 or more of any characters e.g. name_begins = ?onny will return Sonny and Tonny
Specify either project_id or project_name. When project_id is provided (not None), project_name is omitted.
Note
When project_id is None and project_name is None, then its value is overwritten by project_id from connection object.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection()
name (string, optional) – value the search pattern is set to, which will be applied to the names of functions being searched
to_dictionary (bool, optional) – If True returns dict, by default (False) returns SchemaObjectReference objects
search_pattern (SearchPattern enum or int, optional) – pattern to search for, such as Begin With or Exactly. Possible values are available in ENUM mstrio.object_management.SearchPattern. Default value is CONTAINS (4).
project_id (string, optional) – Project ID
project_name (string, optional) – Project name
limit (integer, optional) – limit the number of elements returned. If None all object are returned.
**filters –
Available filter parameters: id str: Attribute’s id name str: Attribute’s name date_created str: format: 2001-01-02T20:48:05.000+0000 date_modified str: format: 2001-01-02T20:48:05.000+0000 version str: function’s version owner dict: e.g. {‘id’: <user’s id>, ‘name’: <user’s name>},
with one or both of the keys: id, name
acg str | int: access control group
- Returns:
list with SchemaObjectReference objects or list of dictionaries
mstrio.modeling.expression.expression_nodes module¶
- class mstrio.modeling.expression.expression_nodes.AttributeFormPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, function: ~mstrio.modeling.expression.enums.Function, attribute: ~mstrio.modeling.schema.helpers.SchemaObjectReference, form: ~mstrio.modeling.schema.helpers.SchemaObjectReference, parameters: list[mstrio.modeling.expression.parameters.PredicateParameter] = <factory>, data_locale: str | None = None)¶
Bases:
PredicateNode
Specialized expression node that contains an attribute form qualification predicate.
This qualification selects elements of a specified attribute by comparing the value of a specified form of the element with an expression. The comparison operator used is also specified. However, there are three options for specifying the expression with which it is compared:
The client may specify a literal value.
The client may ask to use a prompt to determine the value.
The client may supply an arbitrary metric style expression to evaluate to
obtain the value.
- function¶
Specify the comparison function that should be used to compare the value computed by the filter with an expression value.
- parameters¶
list of objects that correspond to the parameters for the comparison function. In nearly all cases the comparison function will take one extra parameter (in addition to the parameter referenced by the predicate’s main object).
This value is a list because there are a few functions which take a different number of extra parameters. For example isNull does not need any additional parameters; notBetween needs two additional parameters.
- attribute¶
The attribute whose elements are selected by this qualification
- form¶
The attribute form whose value is used to specify the qualification
- data_locale¶
Optional data locale used to select values of the form. The format should follow the IETF BCP 47 language tag, for example: “en-US”.
Some forms of some attributes may be configured to store representation in multiple locales. If a predicate qualifies on a form that has been translated in this manner it is likely that the elements selected by the predicate will be different for different locales. But we do not want the meaning of a filter to vary based on the locale preferences of the user executing the filter. So this property is used to specify the data locale to be used for the qualification. When set it will override the user’s personal data locale preference.
Retrieving a filter only returns this field if the form is multilingual. If the form is multilingual but no particular locale is set, an empty string will be returned. When updating or creating a filter, again a check will be made to see if the form is capable of being multilingual. If not, users inputs are ignored. If the form is indeed multilingual and the field is omitted from the input, the locale will default to the warehouse data locale of the user.
- Type:
str | None
- attribute: SchemaObjectReference¶
- data_locale: str | None = None¶
- form: SchemaObjectReference¶
- parameters: list[mstrio.modeling.expression.parameters.PredicateParameter]¶
- class mstrio.modeling.expression.expression_nodes.BandingCountPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference], metric: SchemaObjectReference, band_metric_function: BandMetricFunction, start: Variant, stop: Variant, count: Variant, band_names: list[str] | None = None)¶
Bases:
BandingPredicate
The Band count type of banding qualification slices a range of metric values into a number of equal bands that appear as rows on a report.
You define the range by setting the start at and stop at values. You also set the band count, which is the number of bands to use.
- start¶
the start of the range
- stop¶
the end of the range
- count¶
number of bands
- band_names: list[str] | None = None¶
- class mstrio.modeling.expression.expression_nodes.BandingDistinctPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference], metric: SchemaObjectReference, band_metric_function: BandMetricFunction)¶
Bases:
BandingPredicate
The Band for each distinct metric value type of banding qualification creates a separate band for each value calculated by the metric. The bands appear as rows on a report. This type of banding qualification directly uses the results of a metric as bands.
It is very useful with metrics that already contain the logic needed to calculate sequential band numbers. Such metrics use mathematical formulas, NTile functions, Band functions, or Case functions.
- class mstrio.modeling.expression.expression_nodes.BandingPointsPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference], metric: SchemaObjectReference, band_metric_function: BandMetricFunction, points: list[float], band_names: list[str] | None = None)¶
Bases:
BandingPredicate
The Banding points type of banding qualification slices a range of metric values into a number of bands that appear as rows on a report.
You manually define each band, which allows you to produce bands of varying sizes.
- points¶
list of number used to slice metric values into bands
- Type:
list[float]
- band_names: list[str] | None = None¶
- points: list[float]¶
- class mstrio.modeling.expression.expression_nodes.BandingPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference], metric: SchemaObjectReference, band_metric_function: BandMetricFunction)¶
Bases:
PredicateNode
Base class for banding predicates
- level¶
level at which the computation will be performed
- metric¶
metric for which this banding will be applied
- band_metric_function¶
function used to slice metric values into bands
- band_names¶
list of band names, a band name cannot contain “#;” or “#,”
- class BandMetricFunction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant used to specify function used to slice metric values into bands
- PERCENTILE_DESCEND = 'percentile_descend'¶
- RANK_DESCEND = 'rank_descend'¶
- VALUE = 'value'¶
- band_metric_function: BandMetricFunction¶
- metric: SchemaObjectReference¶
- class mstrio.modeling.expression.expression_nodes.BandingSizePredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference], metric: SchemaObjectReference, band_metric_function: BandMetricFunction, start: Variant, stop: Variant, size: Variant, band_names: list[str] | None = None)¶
Bases:
BandingPredicate
The Band size type of banding qualification slices a range of metric values into a number of bands that appear as rows on a report.
You define the range by setting the start at and stop at values. You also set the step size, which is the size of each band.
- start¶
the start of the range
- stop¶
the end of the range
- size¶
the size of each band
- band_names: list[str] | None = None¶
- class mstrio.modeling.expression.expression_nodes.ColumnReference(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, column_name: str, object_id: str | None = None)¶
Bases:
ExpressionNode
n expression node whose value is some column from a table implied by the expression’s context.
This kind of node is used when we wish to define an expression over the columns of a table or potentially over more than one table. The reference specifies, the column of interest, by name alone. So the reference is to a selected column on the implied table. It is not a reference to a specific column on a specific table. Defining a column reference in this manner allows the architect to specify an expression that can be usefully applied to more than one table.
- column_name¶
The name of the column, as it appears within the RDBMS.
- Type:
str
- object_id¶
A globally unique identifier used to distinguish between metadata objects within the same project. It is possible for two metadata objects in different projects to have the same Object id.
- Type:
str | None
- column_name: str¶
- object_id: str | None = None¶
- class mstrio.modeling.expression.expression_nodes.Constant(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, variant: mstrio.modeling.expression.parameters.Variant | None = None, prompt: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None)¶
Bases:
ExpressionNode
An expression node that contains a literal value. The value was fixed when the expression node was first specified. This kind of node is only used for simple values (integers, floating point numbers and text strings).
Alternatively, instead of the variant the node could contain a choose-value prompt reference.
- variant¶
constant value specified as Variant
- Type:
- prompt¶
reference to a prompt
- Type:
- prompt: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- variant: mstrio.modeling.expression.parameters.Variant | None = None¶
- class mstrio.modeling.expression.expression_nodes.CustomExpressionPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, expression: Expression, node_property: int | None = None)¶
Bases:
PredicateNode
Specialized expression node that contains a custom expression predicate. This qualification contains a valid expression, usually created by the user, which can’t be categorized into other types.
The expression is represented by a list of tokens. The predicate has the predicate details which contains the tokens representing the expression. It’s controlled by the showPredicates to show or hide.
- expression¶
Generic specification for calculation, instance of Expression class
- node_property¶
A property used for persisting back-compatibility information for the filter editing. Usually it will not show.
- Type:
int | None
- expression: Expression¶
- node_property: int | None = None¶
- class mstrio.modeling.expression.expression_nodes.DynamicDateTime(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, value: DynamicDateTimeStructure)¶
Bases:
ExpressionNode
An expression node that represents Dynamic Date Time.
- value¶
an object that represents date and/or time.
- Type:
- value: DynamicDateTimeStructure¶
- class mstrio.modeling.expression.expression_nodes.ElementListPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, attribute: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, elements: list[mstrio.modeling.expression.parameters.AttributeElement] | None = None, elements_prompt: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, function: ElementListFunction = ElementListFunction.IN)¶
Bases:
PredicateNode
Specialized expression node that contains an element list predicate.
This qualification selects elements of a specified attribute by either listing the elements that should be selected, or alternatively by listing the elements that should be excluded from the selection.
- attribute¶
The attribute whose elements are selected by this qualification. Property is not needed if the predicate uses a prompt since in that case the attribute is specified by the prompt.
- Type:
- elements¶
List of the elements in the predicate
- Type:
list[mstrio.modeling.expression.parameters.AttributeElement] | None
- elements_prompt¶
A choose-elements prompt used to obtain the elements in the qualification. If this object is used then it will specify the attribute and elements for the qualification. The prompt will specify an attribute from which the elements should be selected.
- Type:
- function¶
Specify the function that should be used in this predicate.
Although this property is a function identifier, there are only two functions that make sense for this predicate:
IN (the filter accepts any element in the list, default value)
NOT_IN (the filter accepts any element not included in the list)
- class ElementListFunction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant that describes what functions can be used within ElementListPredicate
- IN = 'in'¶
- NOT_IN = 'not_in'¶
- attribute: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- elements: list[mstrio.modeling.expression.parameters.AttributeElement] | None = None¶
- elements_prompt: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- function: ElementListFunction = 'in'¶
- class mstrio.modeling.expression.expression_nodes.ExpressionFormShortcut(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, attribute: SchemaObjectReference, form: SchemaObjectReference, data_locale: str | None = None)¶
Bases:
ExpressionNode
An expression node that represents shortcut to an expression form.
- attribute¶
Information about an object referenced within the specification of another object. An object reference typically contains only enough fields to uniquely identify the referenced objects.
- Type:
- form¶
Information about an object referenced within the specification of another object. An object reference typically contains only enough fields to uniquely identify the referenced objects.
- Type:
- data_locale¶
Optional data locale used to select values of the form. The format should follow the IETF BCP 47 language tag, for example: “en-US”.
Some forms of some attributes may be configured to store representation in multiple locales. If a predicate qualifies on a form that has been translated in this manner it is likely that the elements selected by the predicate will be different for different locales. But we do not want the meaning of a filter to vary based on the locale preferences of the user executing the filter. So this property is used to specify the data locale to be used for the qualification. When set it will override the user’s personal data locale preference.
- Type:
str
- attribute: SchemaObjectReference¶
- data_locale: str | None = None¶
- form: SchemaObjectReference¶
- class mstrio.modeling.expression.expression_nodes.ExpressionRelationship(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference], guide: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, is_independent: IsIndependent = IsIndependent.YES, children: list[mstrio.modeling.expression.expression.ExpressionNode] | None = None)¶
Bases:
ExpressionNode
An expression node that represents expression relationship.
- level¶
Within an expression we sometimes need to state at which a computation is performed. In some cases the level is obtained by examining the execution environment. This object is used if the designer wishes to specify an explicit level.
An explicit level is a list of attributes. Alternatively the client may defer selecting an attribute (or attributes) at design time by using a prompt instead. If a prompt is used it should be a choose-attributes prompt, and it may return any number of attributes (including zero).
- guide¶
An optional object that specifies how to relate the child filter with the output filter. There are three options, depending on the nature of the guide object:
The object may be a logicalTable, in which case the filter is
projected through this table.
The object may be a fact, in which case the filter is projected
via one of the tables on which the fact is defined.
There might not be a guide object at all, in which case the
filter is projected via the engine’s usual join rules (using attribute relationships from the system hierarchy).
- Type:
- is_independent¶
Flag that indicates whether this child filter will be considered independently of other parts of the larger filter:
If set to 1 (the default value, used if this property is omitted)
then this filter will be evaluated by itself.
If set to 0 then other parts of the larger filter will be merged
into this filter. Using this setting could change the value of a metric or relationship set qualification that appears within the child filter.
- children¶
List containing the optional root node of the child filter expression. We require that a relationship predicate always has a child filter is always given, but it is possible that the child filter is the empty filter. We model that situation by either omitting the children value or by using an empty list.
This expression is also a filter expression, and it is manipulated in the same manner as the rest of the filter. The predicate ids that appear within this expression must have disjoint values from the predicate ids used in the larger filter. Thus, an individual node within this expression can be manipulated by treating it as a manipulation of the larger filter in the usual manner.
We use a list so that this value matches the list value of the same name used in an operator node.
- Type:
list[mstrio.modeling.expression.expression.ExpressionNode] | None
- children: list[mstrio.modeling.expression.expression.ExpressionNode] | None = None¶
- classmethod from_dict(source: dict, connection: Connection = None, to_snake_case: bool = True) ExpressionRelationship ¶
Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of an object that should be created.
source (Dict[str, Any]) – A dictionary from which an object will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
An object of type T.
- Return type:
T
- guide: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- is_independent: IsIndependent = 1¶
- to_dict(camel_case: bool = True) dict ¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- class mstrio.modeling.expression.expression_nodes.FilterQualificationPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, filter: SchemaObjectReference, is_independent: IsIndependent = IsIndependent.YES)¶
Bases:
PredicateNode
Specialized expression node that contains a filter qualification predicate.
This node is used within filter expressions to represent a predicate whose value is determined by using an external filter object. At execution time the engine will typically act as if the specified filter had been included directly. By using shared filter objects, the client can build complex filter expressions to utilise common subexpressions.
A filter object may not reference itself, or any filter that depends on itself. If such a filter is saved to the metadata any calculation that uses the filter will fail.
- filter¶
Reference to the child filter that should be included in this predicate.
- is_independent¶
Flag that indicates whether this child filter will be considered independently of other parts of the larger filter:
If set to 1 (the default value, used if this property is omitted)
then this filter will be evaluated by itself.
If set to 0 then other parts of the larger filter will be merged
into this filter. Using this setting could change the value of a metric or relationship set qualification that appears within the child filter.
- filter: SchemaObjectReference¶
- is_independent: IsIndependent = 1¶
- class mstrio.modeling.expression.expression_nodes.JointElementListPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference], tuples: list[list[mstrio.modeling.expression.parameters.AttributeElement]])¶
Bases:
PredicateNode
Specialized expression node that contains a joint element list predicate.
This qualification represents a filter at the level of two or more attributes. The filter is defined by simply listing the tuples of elements that satisfy the filter.
- level¶
The level of this filter represented as a list of attributes. The attributes must be different from each other, and their order is significant.
- tuples¶
List of tuples of elements.
Each element of this list is a joint element. That is the members of this list are themselves lists of elements. The elements in the tuples must be listed in the same order as the attributes were listed in the level list. There is no need to list the attribute on each element.
- Type:
list[list[mstrio.modeling.expression.parameters.AttributeElement]]
- tuples: list[list[mstrio.modeling.expression.parameters.AttributeElement]]¶
- class mstrio.modeling.expression.expression_nodes.MetricPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, function: ~mstrio.modeling.expression.enums.Function, metric: ~mstrio.modeling.schema.helpers.SchemaObjectReference, level_type: str, parameters: list[mstrio.modeling.expression.parameters.PredicateParameter] = <factory>, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference] | None = None, metric_function: mstrio.modeling.expression.expression_nodes.MetricPredicate.MetricFunction | None = None, null_include: int | None = None, break_by: list[mstrio.modeling.schema.helpers.SchemaObjectReference] | None = None, is_independent: ~mstrio.modeling.expression.enums.IsIndependent = IsIndependent.YES)¶
Bases:
PredicateNode
Specialized expression node that contains a metric qualification predicate.
This qualification selects tuples of elements at a specified level by comparing the value of a specified metric evaluated at the tuple with a value of an expression. The comparison operator used is also specified. However, there are multiple options for specifying the expression with which the metric is compared:
The client may specify a literal value.
The client may specify an object reference.
The client may ask to use a prompt to determine the value.
The client may supply an arbitrary metric style expression to evaluate to obtain the value.
- function¶
Specify the comparison function that should be used to compare the value computed by the filter with an expression value.
- metric¶
The metric over whose values this qualification is evaluated.
- parameters¶
List of objects that correspond to the parameters for the comparison function. In nearly all cases the comparison function will take one extra parameter (in addition to the parameter referenced by the predicate’s main object).
- level_type¶
Enumeration value indicating how the predicate’s level should be determined. If there is a level it is usually taken to be the same level as is used in the display grid, or which was used to obtain the data. There is also an option to specify an absolute level as part of the predicate definition.
- Type:
str
- level¶
Within an expression we sometimes need to state at which a computation is performed. In some cases the level is obtained by examining the execution environment. This object is used if the designer wishes to specify an explicit level. An explicit level is a list of attributes. Alternatively the client may defer selecting an attribute (or attributes) at design time by using a prompt instead. If a prompt is used it should be a choose-attributes prompt, and it may return any number of attributes (including zero).
- Type:
list[mstrio.modeling.schema.helpers.SchemaObjectReference] | None
- metric_function¶
Optional parameter that describes how the metric is used within the predicate. If this parameter is omitted it is treated as if it had been set to value.
- null_include¶
NullInclude is an integer parameter which specifies how null values are considered when evaluating the Rank function. Use 1 to place null values after the value list, use -1 to place null values before the value list or use 0 to apply the Null checking setting for Analytical Engine in VLDB properties. If this value is not set, 0 will be applied.
- Type:
int | None
- break_by¶
The break by property of a metric qualification allows you to choose the attribute level at which to restart counting rank or percent values for a metric. This attribute level must be higher than or equal to the level of aggregation for the metric itself. break_by is a list of distinct attribute references. The list may also contain a choose-attribute prompt instead which can be answered with zero, one or more attributes. This value is only used when the metric_function property is not set to value.
- Type:
list[mstrio.modeling.schema.helpers.SchemaObjectReference] | None
- is_independent¶
Flag that indicates whether the metric will be evaluated independently of other parts of the larger filter: - If set to 1 (the default value, also used if this property is
omitted) then this metric will be evaluated by itself.
- If set to 0 then other parts of the larger filter will be applied
when evaluating the metric.
- class MetricFunction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant that describes how the metric is used within the predicate.
- PERCENTILE_ASCEND = 'percentile_ascend'¶
- PERCENTILE_DESCEND = 'percentile_descend'¶
- RANK_ASCEND = 'rank_ascend'¶
- RANK_DESCEND = 'rank_descend'¶
- VALUE = 'value'¶
- break_by: list[mstrio.modeling.schema.helpers.SchemaObjectReference] | None = None¶
- is_independent: IsIndependent = 1¶
- level: list[mstrio.modeling.schema.helpers.SchemaObjectReference] | None = None¶
- level_type: str¶
- metric: SchemaObjectReference¶
- metric_function: mstrio.modeling.expression.expression_nodes.MetricPredicate.MetricFunction | None = None¶
- null_include: int | None = None¶
- parameters: list[mstrio.modeling.expression.parameters.PredicateParameter]¶
- class mstrio.modeling.expression.expression_nodes.ObjectReference(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, target: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, is_independent: IsIndependent = IsIndependent.YES, substitute_function_type: mstrio.modeling.expression.expression_nodes.ObjectReference.SubstituteFunctionType | None = None)¶
Bases:
ExpressionNode
An expression node whose value is a reference to some other object in the metadata.
The meaning of the reference depends on the context. If the referenced object is an object that is based on an expression (say a filter or a metric) then it usually means we inline the expression from the object. But in other cases (say a fact) it means that on execution the object reference is replaced with a value of the fact in the context of execution.
Although unusual, it is possible that an object reference node might not refer to an object. If that happens this target property is usually omitted (but might be present but use 00000000000000000000000000000000 as its object_id).
The object could be a prompt to select the target object at runtime. Typically, it is not acceptable for the prompt to return more than one answer.
- target¶
object being referenced
- Type:
- is_independent¶
Flag that indicates whether this child filter will be considered independently of other parts of the larger filter:
If set to 1 (the default value, used if this property is omitted)
then this filter will be evaluated by itself.
If set to 0 then other parts of the larger filter will be merged
into this filter. Using this setting could change the value of a metric or relationship set qualification that appears within the child filter.
- substitute_function_type¶
Specify how to merge multiple answers if the predicate’s value is obtained via a prompt. This property is only used when filter’s value is a prompt. If the end user selects multiple answers to the prompt, the platform will replace this node by a Boolean operator, used to combine the answers. This property determines which operator it uses. By default, it uses the parent Boolean operator (or AND if this predicate is the root of the filter). Set this property to override the default behavior.
- class SubstituteFunctionType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant that specify how to merge multiple answers if the predicate’s value is obtained via a prompt.
- AND = 'and'¶
- OR = 'or'¶
- is_independent: IsIndependent = 1¶
- substitute_function_type: mstrio.modeling.expression.expression_nodes.ObjectReference.SubstituteFunctionType | None = None¶
- target: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- class mstrio.modeling.expression.expression_nodes.Operator(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, children: list[mstrio.modeling.expression.expression.ExpressionNode] | None = None, function: mstrio.modeling.expression.enums.Function | None = None, function_properties: list[mstrio.modeling.expression.parameters.FunctionProperty] | None = None, function_prompt: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, level_type: mstrio.modeling.expression.expression_nodes.Operator.LevelType | None = None, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference] | None = None, node_property: int | None = None, custom_function: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None)¶
Bases:
ExpressionNode
An expression node whose value is obtained by applying a specified function to a list of child expressions. Most internal nodes within an expression are operator nodes.
- children¶
The list of child expression that combined at this operator. If there are multiple child expressions then their order is significant. In a few cases (depending on the function) it is valid for an operator node to have no children, in which case this member property may be omitted.
- Type:
list[mstrio.modeling.expression.expression.ExpressionNode] | None
- function¶
Enumeration constant that identifies all the built-in functions. This value will always be provided when the service generates the object. When the client generates the object it may use this field by itself to specify the function. This value by itself is insufficient to identify the function if it is set to CUSTOM or THIRD_PARTY, in which case the custom_function value must be provided. This property is required in the predicate model but can be replaced by ‘function_prompt’ in the expression model.
- Type:
- function_properties¶
The list of additional properties associated with the function. This is most useful when the function is ‘RANK’, as we’ll need the “by_value” and “ascending” properties. This field is only used in a custom expression tree.
- Type:
list[mstrio.modeling.expression.parameters.FunctionProperty] | None
- function_prompt¶
The prompt used by this function. This field is only used in a custom expression tree.
- Type:
- level_type¶
Enumeration value indicating how the predicate’s level should be determined.
If there is a level it is usually taken to be the same level as is used in the display grid, or which was used to obtain the data. There is also an option to specify an absolute level as part of the predicate definition.
This field is only used in a custom expression tree.
- level¶
This field is only used in a custom expression tree.
- Type:
list[mstrio.modeling.schema.helpers.SchemaObjectReference] | None
- node_property¶
A property used for persisting back-compatibility information for the filter editing. Usually it will not show. If it’s displayed in the response, you should consider include it with the same value in the same node in the request body when you’re performing the PUT/POST/PATCH.
If you don’t put it back in the request, there can be some behavior difference in Filter Expression Editors of other MicroStrategy apps.
- Type:
int | None
- class LevelType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration value indicating how the predicate’s level should be determined
- EXPLICIT_LEVEL = 'explicit_level'¶
- GRID_LEVEL = 'grid_level'¶
- METRIC_LEVEL = 'metric_level'¶
- NONE = 'none'¶
- children: list[mstrio.modeling.expression.expression.ExpressionNode] | None = None¶
- custom_function: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- function: mstrio.modeling.expression.enums.Function | None = None¶
- function_prompt: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- function_properties: list[mstrio.modeling.expression.parameters.FunctionProperty] | None = None¶
- level: list[mstrio.modeling.schema.helpers.SchemaObjectReference] | None = None¶
- level_type: mstrio.modeling.expression.expression_nodes.Operator.LevelType | None = None¶
- node_property: int | None = None¶
- class mstrio.modeling.expression.expression_nodes.PredicateNode(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None)¶
Bases:
ExpressionNode
Base class for all predicate nodes.
- predicate_id¶
String identifier that uniquely identifies this predicate within the context of its larger filter. Any non-empty string of printable characters can be used as a predicate.
- Type:
str | None
- predicate_text¶
Text representation of a predicate
- Type:
str | None
- classmethod from_dict(source: dict, connection: Optional[Connection] = None, to_snake_case: bool = True) type['PredicateNode'] ¶
Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of an object that should be created.
source (Dict[str, Any]) – A dictionary from which an object will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
An object of type T.
- Return type:
T
- predicate_id: str | None = None¶
- predicate_text: str | None = None¶
- to_dict(camel_case: bool = True) dict ¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- class mstrio.modeling.expression.expression_nodes.PromptPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, prompt: SchemaObjectReference)¶
Bases:
PredicateNode
Specialized expression node for a predicate whose value is prompted at execution time.
This predicate is used for various kinds of expression prompts. At execution time the end user in effect enters an entire predicate (or an even more complex expression). The answer is then substituted into the filter in place of this node.
- prompt¶
reference to a prompt, whose value is prompted at execution
- prompt: SchemaObjectReference¶
- class mstrio.modeling.expression.expression_nodes.ReportQualificationPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, report: SchemaObjectReference)¶
Bases:
PredicateNode
Specialized expression node that contains a report qualification predicate.
This node is used within filter expressions to represent a predicate whose value is determined by using a report as filter. That is the engine will evaluate a report, and determine the rows that it covers. These filter will consist of these rows.
- report¶
Reference to the child report that should be included in this predicate.
- report: SchemaObjectReference¶
- class mstrio.modeling.expression.expression_nodes.SetFromRelationshipPredicate(*, expression_type: mstrio.modeling.expression.enums.ExpressionType | None = None, dimty_type: mstrio.modeling.expression.enums.DimtyType | None = None, dependence_type: mstrio.modeling.expression.enums.DependenceType | None = None, predicate_id: str | None = None, predicate_text: str | None = None, level: list[mstrio.modeling.schema.helpers.SchemaObjectReference], guide: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None, is_independent: IsIndependent = IsIndependent.YES, children: list[mstrio.modeling.expression.expression.ExpressionNode] | None = None)¶
Bases:
PredicateNode
Specialized expression node that contains a relationship set qualification predicate. In words this predicate describes a qualification of the form “SET of WHERE”.
This node is used within filter expressions to represent a predicate whose value is determined by starting with an arbitrary filter expression at some natural level. This filter is then projected to a filter at a level specified within this predicate by using a relationship. The relationship might be the natural relationship inferred by the engine for the schema, the relationship given by an explicit table, or a relationship implied by a fact (i.e. the engine selects the best table from the set of tables where the given fact is implemented).
This predicate is the only kind of filter predicate that may have a child expression.
- level¶
Within an expression we sometimes need to state at which a computation is performed. In some cases the level is obtained by examining the execution environment. This object is used if the designer wishes to specify an explicit level.
An explicit level is a list of attributes. Alternatively the client may defer selecting an attribute (or attributes) at design time by using a prompt instead. If a prompt is used it should be a choose-attributes prompt, and it may return any number of attributes (including zero).
- guide¶
An optional object that specifies how to relate the child filter with the output filter. There are three options, depending on the nature of the guide object:
The object may be a logicalTable, in which case the filter is projected through this table. The object may be a fact, in which case the filter is projected via one of the tables on which the fact is defined. There might not be a guide object at all, in which case the filter is projected via the engine’s usual join rules (using attribute relationships from the system hierarchy).
- Type:
- is_independent¶
Flag that indicates whether this child filter will be considered independently of other parts of the larger filter:
If set to 1 (the default value, used if this property is omitted)
then this filter will be evaluated by itself.
If set to 0 then other parts of the larger filter will be merged
into this filter. Using this setting could change the value of a metric or relationship set qualification that appears within the child filter.
- children¶
List containing the optional root node of the child filter expression. We require that a relationship predicate always has a child filter is always given, but it is possible that the child filter is the empty filter. We model that situation by either omitting the children value or by using an empty list.
This expression is also a filter expression, and it is manipulated in the same manner as the rest of the filter. The predicate ids that appear within this expression must have disjoint values from the predicate ids used in the larger filter. Thus, an individual node within this expression can be manipulated by treating it as a manipulation of the larger filter in the usual manner.
We use a list so that this value matches the list value of the same name used in an operator node.
- Type:
list[mstrio.modeling.expression.expression.ExpressionNode] | None
- children: list[mstrio.modeling.expression.expression.ExpressionNode] | None = None¶
- guide: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- is_independent: IsIndependent = 1¶
mstrio.modeling.expression.fact_expression module¶
- class mstrio.modeling.expression.fact_expression.FactExpression(expression: Expression, tables: list[mstrio.modeling.schema.helpers.SchemaObjectReference], id: str | None = None)¶
Bases:
Dictable
Object that gives information about an expression that is in use by a fact or an attribute. Naturally the most important part of a fact expression is the expression. This is often just a single column reference, but more complex expressions are supported. The object also lists those tables where the expression is currently used or where it could be used.
We say that a table supports a fact if it is possible to compute a value for the fact by means of a SELECT expression for each row of the table. The expression represents a SELECT expression.
- Parameters:
id (str) – FactExpression’s id, a globally unique identifier used to
project. (distinguish between metadata objects within the same) –
expression (Expression) – A generic specification for a calculation
a (nodes at all. An expression is empty if and only if it does not have) –
nodes (tree over nodes. Most internal) –
nodes. (defined by applying a function to the operator's child) –
cases (Usually an expression must be non-empty. But in a few) –
most –
no (notably a filter expression it is valid for an expression to contain) –
a –
property. (tree) –
list (Alternatively the client may prefer to handle an expression as a) –
the (of tokens. Each token represents part of the raw text of) –
expression –
information. (in some cases annotated with additional) –
tables (List[SchemaObjectReference]) – Array with a member object for
evaluating (each logical table that computes a value for this fact by) –
expression. (the) –
saved (This array should be non-empty for a fact or an attribute that is) –
metadata (into) –
of (but may be empty during an edit changeset. The order) –
significance. (the tables within the array has no) –
- expression: Expression¶
- classmethod from_dict(source: dict, connection: Optional[Connection] = None, to_snake_case: bool = True) FactExpression ¶
Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of an object that should be created.
source (Dict[str, Any]) – A dictionary from which an object will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
An object of type T.
- Return type:
T
- id: str | None = None¶
- local_alter(expression: Expression = None, tables: list[mstrio.modeling.schema.helpers.SchemaObjectReference] = None)¶
Locally alters the Fact Expression
- Parameters:
expression – Expression object that will replace the current Expression representing the calculations required for this fact
tables – array of schema object references that will replace the current array with logical tables needed to represent this fact
- tables: list[mstrio.modeling.schema.helpers.SchemaObjectReference]¶
- to_dict(camel_case: bool = True) dict ¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
mstrio.modeling.expression.parameters module¶
- class mstrio.modeling.expression.parameters.AttributeElement(display: str, element_id: str, attribute: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None)¶
Bases:
Dictable
This object represents a concrete element. A concrete element is a metadata representation of an element that exists in some data source.
Since an external data source can be modified without using the MicroStrategy Platform, the existence of a concrete element in the metadata does not mean that the element described currently exists. It means that it existed at some point.
- display¶
Human readable string to display to describe the element to a reader
- Type:
str
- element_id¶
Opaque string value that identifies the element to the service.
The client should make no assumption about the format of this string, and should not attempt to parse it (even though forms of the element are likely to be visibly concatenated into it). This string will remain valid even if the current client is using a different locale to the locale of the client that created the element.
When creating an element, the client should copy this string from other fields of the element browse result. If a “terse” element id is used, the service will need to know the attribute in order to decode the element id.
- Type:
str
- attribute¶
Optionally the element may specify the attribute that it uses
Note that in most cases elements are used in a context in which the attribute value is implied (for example the element is part of an IN-list of elements for some attribute). if the attribute is implied there is no need to redundantly repeat it on each element in the collection.
- Type:
- attribute: mstrio.modeling.schema.helpers.SchemaObjectReference | None = None¶
- display: str¶
- element_id: str¶
- class mstrio.modeling.expression.parameters.ConstantArrayParameter(constants_type: VariantType, constants: list[str])¶
Bases:
PredicateParameter
Object used to describe a parameter that appears in a filter predicate and whose value is a list of constants.
This kind of parameter is very specific. It is used for the IN and NOT_IN comparison functions. These functions compare one value with an array of constant values. Note that all the values in the array must have the same type.
- constants_type¶
Identifies the type of values in constants attribute
- constants¶
list of constant values, each of which is encoded as a string in a standard, locale-neutral representation. Their common datatype is given by constants_type.
- Type:
list[str]
- constants: list[str]¶
- constants_type: VariantType¶
- class mstrio.modeling.expression.parameters.ConstantParameter(constant: Variant)¶
Bases:
PredicateParameter
Object used to describe a parameter that appears in a filter predicate and whose value is constant.
- constant¶
representation of constant as Variant object
- class mstrio.modeling.expression.parameters.DynamicDateTimeParameter(dynamic_date_time: DynamicDateTimeStructure)¶
Bases:
PredicateParameter
Object used to describe a parameter that appears in a filter predicate and whose value is a dynamic date/time.
- dynamic_date_time¶
Object that represents a date/time.
- dynamic_date_time: DynamicDateTimeStructure¶
- class mstrio.modeling.expression.parameters.ExpressionParameter(expression: Expression)¶
Bases:
PredicateParameter
Object used to describe a parameter that appears in a filter predicate and whose value is given as a custom expression.
This predicate parameter option is used for when the end user wants to provide a custom expression for the predicate. We would expect the parser to be used to modify the expression.
- expression¶
custom expression, instance of Expression class
- expression: Expression¶
- class mstrio.modeling.expression.parameters.FunctionProperty(name: str, value: Variant)¶
Bases:
Dictable
Additional properties associated with a function.
- name¶
function’s property name
- Type:
str
- value¶
function’s property value
- name: str¶
- class mstrio.modeling.expression.parameters.ObjectReferenceParameter(target: SchemaObjectReference)¶
Bases:
PredicateParameter
Object that describe a parameter that appears in a filter predicate and whose value is an object reference.
For example, a parameter of this type would be used by a filter predicate that compares the value of two metrics. This would be modelled by using a metric predicate (containing one of the two metrics); this parameter would then be used to record the other metric.
- target¶
reference to object
- target: SchemaObjectReference¶
- class mstrio.modeling.expression.parameters.ParameterType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating type of parameter
- ARRAY = 'array'¶
- CONSTANT = 'constant'¶
- DYNAMIC_DATE_TIME = 'dynamic_date_time'¶
- EXPRESSION = 'expression'¶
- OBJECT_REFERENCE = 'object_reference'¶
- PROMPT = 'prompt'¶
- class mstrio.modeling.expression.parameters.PredicateParameter¶
Bases:
Dictable
Base class for parameters
- static dispatch(source, connection: Optional[Connection] = None) type['PredicateParameter'] ¶
- Returns an appropriate PredicateParameter object from the
provided source
- Parameters:
source – object that specifies PredicateParameter that will be returned
connection (optional) – MicroStrategy connection object returned
connection.Connection() (by) –
- to_dict(camel_case: bool = True) dict ¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- class mstrio.modeling.expression.parameters.PromptParameter(prompt: SchemaObjectReference)¶
Bases:
PredicateParameter
Object used to describe a parameter that appears in a filter predicate and whose value will be obtained on execution by resolving a prompt object.
The prompt could be any type of prompt that returns a simple value: integer prompt, double prompt, big-decimal prompt, string prompt or date prompt. The prompt should be consistent with the data type of the value to be compared with the prompt.
- prompt¶
reference to prompt object
- prompt: SchemaObjectReference¶
- class mstrio.modeling.expression.parameters.Variant(type: VariantType, value: str)¶
Bases:
Dictable
The typed value used in the predicates
- type¶
Identifies the type of value attribute
- value¶
The value, encoded as a string in a standard, locale-neutral, format.
- Type:
str
- type: VariantType¶
- value: str¶
- class mstrio.modeling.expression.parameters.VariantType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Enumeration constant indicating type of value of a variant object
- BOOLEAN = 'boolean'¶
- DATE = 'date'¶
- DATE_TIME = 'date_time'¶
- DOUBLE = 'double'¶
- INT32 = 'int32'¶
- INT64 = 'int64'¶
- STRING = 'string'¶
- TIME = 'time'¶