mstrio > modeling > expression > fact_expression

class mstrio.modeling.expression.fact_expression.FactExpression(expression, tables, id=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) –

classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)

Creates multiple objects from a list of dictionaries. For each dictionary provided the 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 the object’s _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of the objects that should be created.

  • source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects 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) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

A list of objects of type T.

Return type:

T

classmethod from_dict(source, connection=None, to_snake_case=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

local_alter(expression=None, tables=None)

Locally alters the Fact Expression

Parameters:
  • expression (Expression) – Expression object that will replace the current Expression representing the calculations required for this fact

  • tables (list[SchemaObjectReference]) – array of schema object references that will replace the current array with logical tables needed to represent this fact

to_dict(camel_case=True)

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

expression: Expression
id: str | None = None
tables: list[SchemaObjectReference]