mstrio > modeling > schema > table > logical_table

class mstrio.modeling.schema.table.logical_table.LogicalTable(connection, id=None, name=None, project_id=None, project_name=None)

Bases: Entity, DeleteMixin, MoveMixin

An object representation of a logical table, referred to as Table in Command Manager. A logical table describes the higher-level data model objects (facts, attributes, etc.) that the architect wishes to use to model the contents of the physical table.

A logical table cannot exist without a physical table. Each logical table is mapped to exactly one physical table. However, a physical table may be mapped to many logical tables (each additional one is called logical table alias). This class exposes interface to create both logical and logical table alias.

After performing a write operation on a LogicalTable object, you may want to reload the schema using mstrio.modeling.schema.schema_management module.

Parameters:
  • connection (Connection) –

  • id (str | None) –

  • name (str | None) –

  • project_id (str | None) –

  • project_name (str | None) –

name

name of the logical table

id

id of the logical table

description

description of the logical table

sub_type

string literal used to identify the type of a metadata object, ObjectSubType enum

version

object version ID

ancestors

list of ancestor folders

type

object type, ObjectTypes enum

ext_type

object extended type, ExtendedType enum

date_created

creation time, DateTime object

date_modified

last modification time, DateTime object

owner

User object that is the owner

acg

access rights (See EnumDSSXMLAccessRightFlags for possible values)

acl

object access control list

version_id

the version number this object is currently carrying

is_embedded

if true indicates that the target object of this reference is embedded within this object, if this field is omitted (as is usual) then the target is not embedded.

path

the path of the object, read only

primary_locale

the primary locale of the object, in the IETF BCP 47 language tag format, such as “en-US”, read only

destination_folder_id

a globally unique identifier used to distinguish between metadata objects within the same project

logical_size

a size based on the columns in the tables and the attributes to which those columns correspond. Uses the conceptual or logical attribute definitions to assign a size to each table in the project.

is_logical_size_locked

An indication if the logical table size of a table is locked or not. When a table’s logical size is locked, the table is excluded from the logical table size calculation when a schema update is performed.

is_part_of_partition

An indication whether this table is part of a partition table.

is_true_key

An indication whether a specified primary key is the true key.

table_key

A list of objects representing table keys defined on physical table

partition_level

List of objects representing partition attributes

attributes

list of objects representing business concepts reflected in data. Attributes provide a context in which to report on and analyze business facts or calculations.

facts

list of objects representing essential elements within the business data model and basis for almost all metrics. They relate numeric data values from the data warehouse to the Strategy One reporting environment. E.g. sales dollars, units sold, profit etc.

primary_data_source

Table’s data can be from different data sources. Primary data source is the first option for table’s data source.

enclose_sql_in_parentheses

This property is only applied if a logical table is based upon a free form sql table. By default, this property value is set to true. This encloses the entire SQL that you typed in the sqlStatement field in parentheses when the SQL statement is executed.

physical_table

Metadata of a physical table based on warehouse’s physical table or free form sql.

partition_tables

A list of objects representing partition’s tables metadata

secondary_data_sources

Strategy One support mapping the table to more than one data source. This attribute is a list of object representations of a reference to a datasource.

hidden

Specifies whether the object is hidden

acl_add(rights, trustees, denied=False, inheritable=None, propagate_to_children=None, propagation_behavior=None)

Add Access Control Element (ACE) to the object ACL.

Note

To add rights for the Root Folder and the Freeform Objects, apply the required rights for these folders:

  • Root Folder: D43364C684E34A5F9B2F9AD7108F7828

  • Freeform Objects: 93D8CF3849C1F85DC1A48E8B9E4271F1

Argument propagate_to_children is used only for objects with type ObjectTypes.FOLDER.

Parameters:
  • rights (int | Rights | AggregatedRights) – The degree to which the user or group is granted or denied access to the object. The available permissions are defined in Rights and AggregatedRights Enums

  • trustees (list[UserOrGroup] | UserOrGroup) – list of trustees (User or UserGroup objects or ids) to update the ACE for

  • denied (bool) – flag to indicate granted or denied access to the object

  • inheritable (bool | None) – Applies only to folders. If set, any objects placed in the folder inherit the folder’s entry in the ACL.

  • propagate_to_children (bool | None) – used for folder objects only, default value is None, if set to True/False adds propagateACLToChildren keyword to the request body and sets its value accordingly

  • propagation_behavior (PropagationBehavior | str | None) – Behavior of ACL propagation to children.

  • self (Entity) –

Return type:

None

Examples

>>> obj.acl_add(rights=Rights.BROWSE | Rights.EXECUTE,
>>>             trustees=user_obj, denied=True)
acl_alter(rights, trustees, denied=False, inheritable=None, propagate_to_children=None, propagation_behavior=None)

Alter an existing Access Control Element (ACE) of the object ACL.

Note

To alter rights for the Root Folder and the Freeform Objects, change the required rights for these folders:

  • Root Folder: D43364C684E34A5F9B2F9AD7108F7828

  • Freeform Objects: 93D8CF3849C1F85DC1A48E8B9E4271F1

Argument propagate_to_children is used only for objects with type ObjectTypes.FOLDER.

Parameters:
  • rights (int | Rights | AggregatedRights) – The degree to which the user or group is granted or denied access to the object. The available permissions are defined in Rights and AggregatedRights Enums

  • trustees (list[UserOrGroup] | UserOrGroup) – list of trustees (User or UserGroup objects or ids) to update the ACE for

  • denied (bool) – flag to indicate granted or denied access to the object

  • inheritable (bool | None) – Applies only to folders. If set, any objects placed in the folder inherit the folder’s entry in the ACL.

  • propagate_to_children (bool | None) – used for folder objects only, default value is None, if set to True/False adds propagateACLToChildren keyword to the request body and sets its value accordingly

  • propagation_behavior (PropagationBehavior | str | None) – Behavior of ACL propagation to children.

  • self (Entity) –

Return type:

None

Examples

>>> obj.acl_alter(rights=Rights.BROWSE | Rights.EXECUTE,
>>>               trustees=user_obj, denied=True)
acl_remove(rights, trustees, denied=False, inheritable=None, propagate_to_children=None, propagation_behavior=None)

Remove Access Control Element (ACE) from the object ACL.

Note

To remove rights from the Root Folder and the Freeform Objects, remove them from these folders:

  • Root Folder: D43364C684E34A5F9B2F9AD7108F7828

  • Freeform Objects: 93D8CF3849C1F85DC1A48E8B9E4271F1

Argument propagate_to_children is used only for objects with type ObjectTypes.FOLDER.

Parameters:
  • rights (int | Rights | AggregatedRights) – The degree to which the user or group is granted or denied access to the object. The available permissions are defined in Rights and AggregatedRights Enums

  • trustees (list[UserOrGroup] | UserOrGroup) – list of trustees (User or UserGroup objects or ids) to update the ACE for

  • denied (bool) – flag to indicate granted or denied access to the object

  • inheritable (bool | None) – Applies only to folders. If set, any objects placed in the folder inherit the folder’s entry in the ACL.

  • propagate_to_children (bool | None) – used for folder objects only, default value is None, if set to True/False adds propagateACLToChildren keyword to the request body and sets its value accordingly

  • propagation_behavior (PropagationBehavior | str | None) – Behavior of ACL propagation to children.

  • self (Entity) –

Return type:

None

Examples

>>> obj.acl_remove(rights=Rights.BROWSE | Rights.EXECUTE,
>>>                trustees=user_obj, denied=True)
add_translation(translations)

Adds translations to the Object.

Parameters:
  • translations (list[OperationData]) – list of translations to be added to the Object

  • self (Entity) –

Returns:

A list of translations for the Object.

Return type:

list[’Translation’]

alter(name=None, is_true_key=None, logical_size=None, description=None, is_logical_size_locked=None, primary_data_source=None, secondary_data_sources=None, physical_table_object_name=None, physical_table_name=None, physical_table_prefix=None, sql_statement=None, enclose_sql_in_parentheses=None, columns=None, folder_id=None, hidden=None, comments=None, owner=None)

Alters properties specified by keyword arguments.

Parameters:
  • name (Optional[str], optional) – Name of a logical table. Defaults to None.

  • is_true_key (Optional[bool]) – Strategy One requires each table to have a primary key, which is a unique value identifying each distinct data record or row. A primary key can be defined by one or more columns in the table. Strategy One determines the primary key for a table based on the attribute’s mapped to the columns of the table. The key is made up of the lowest level attributes. If these columns are mapped to attributes in Strategy One, then the primary key is represented correctly. In this case, if isTrueKey is returned as true, it indicates specified primary key is the true key. Defaults to None.

  • logical_size (Optional[int], optional) – Size of a logical table. Defaults to None.

  • description (str, optional) – Logical table description

  • is_logical_size_locked (Optional[bool], optional) – An indication if the logical table size of a table is locked or not. When a table’s logical size is locked, the table is excluded from the logical table size calculation when a schema update is performed. Defaults to None.

  • primary_data_source (Optional[SchemaObjectReference], optional) – Table’s data can be from different data sources. Primary data source is the first option for table’s data source. Defaults to None.

  • | (secondary_data_sources (Optional[List[SchemaObjectReference]) – List[dict]], optional): Strategy One support mapping the table to more than one data source. This attribute is a list of object representations of a reference to a datasource. Defaults to None

  • physical_table_object_name (Optional[str], optional) – A new name of an object (on MSTR server) that represents a physical table mapped to the logical table. Defaults to None.

  • physical_table_name (Optional[str], optional) – A new name of a physical table mapped to the logical table. Defaults to None.

  • physical_table_prefix (Optional[str], optional) – A new prefix for a physical table mapped to the logical table. Defaults to None.

  • sql_statement (Optional[str], optional) – A new SQL statement for physical table mapped to the logical table. Defaults to None.

  • enclose_sql_in_parentheses (Optional[bool], optional) – This encloses the entire SQL that you typed in the sqlStatement field in parentheses when the SQL statement is executed.

  • columns (Optional[List[TableColumn] | List[dict]], optional) – A list of new columns of a physical table mapped to the logical table. Defaults to None.

  • folder_id (Optional[str], optional) – The ID of a folder to which a logical table should be moved. Defaults to None.

  • hidden (bool, optional) – Specifies whether the object is hidden. Default value: False.

  • comments (str, optional) – Comments added to the object. Defaults to None.

  • owner (str | User | None) – (str, User, optional): Owner of the logical table. Defaults to None.

  • Throws

    TypeError if:
    • Attempting to alter a logical table when it depends upon a

      physical table which type is “Warehouse Partition Table”

    • Attempting to alter physical_table_name or

      physical_table_prefix when the logical table depends upon a freeform sql physical table.

    • Attempting to alter sql_statement or columns when the

      logical table depends upon a normal physical table.

  • Examples

    >>> LogicalTable(connection,
                     id='FF529E1446BE3DF75ECD4B8E18618747').alter(
                         name="Altered Name"
                     )
    

  • secondary_data_sources (None | list[SchemaObjectReference] | list[dict]) –

Return type:

None

alter_translation(translations)

Alters translations of the Object.

Parameters:
  • translations (list[OperationData]) – list of translations to be added to the Object

  • self (Entity) –

Return type:

None

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 create(connection, primary_data_source, table_name=None, table_description=None, sub_type=ObjectSubType.LOGICAL_TABLE, destination_folder=None, is_embedded=None, physical_table=None, physical_table_name=None, physical_table_namespace=None, physical_table_type=PhysicalTableType.NORMAL, physical_table_prefix=None, columns=None, sql_statement=None, logical_size=None, is_part_of_partition=None, is_true_key=None, enclose_sql_in_parentheses=None, check_secondary_data_source_table=None, column_merge_option=TableColumnMergeOption.REUSE_ANY, table_prefix_option=None)

Create a new table in a specific project.

Parameters:
  • connection (object) – Strategy One connection object returned by connection.Connection().

  • primary_data_source (object) – 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.

  • table_name (str, optional) – Logical table name

  • table_description (str, optional) – Logical table description

  • sub_type (enum, str, optional) – String literal used to identify the type of a metadata object.

  • destination_folder (object, str, optional) – Globally unique identifier used to distinguish between metadata objects within the same project

  • is_embedded (bool, optional) – if true indicates that the target object of this reference is embedded within this object

  • physical_table (object, dict, optional) – Physical table

  • physical_table_name (str, optional) – Table name

  • physical_table_namespace (str, optional) – Datasource namespace

  • physical_table_type (enum, optional) – Table type

  • physical_table_prefix (str, optional) – Table prefix of the table

  • columns (object, optional) – Columns

  • sql_statement (str, optional) – SQL statement that will be executed against the warehouse to get column data of the physical table.

  • logical_size (int, optional) – Size of a table

  • is_part_of_partition (bool, optional) – whether current table is part of partition table.

  • is_true_key (bool, optional) – Strategy One requires each table to have a primary key, which is a unique value identifying each distinct data record or row. A primary key can be defined by one or more columns in the table. Strategy One determines the primary key for a table based on the attribute’s mapped to the columns of the table. The key is made up of the lowest level attributes. If these columns are mapped to attributes in Strategy One, then the primary key is represented correctly. In this case, if isTrueKey is returned as true, it indicates specified primary key is the true key.

  • enclose_sql_in_parentheses (bool, optional) – This property is only applied to free form sql table. This encloses the entire SQL that you typed in the sqlStatement field in parentheses when the SQL statement is executed.

  • check_secondary_data_source_table (bool, optional) –

    API finds compatible tables in the project. If a compatible table is found, the compatible table object information is returned. If no table is found, a new table is created. Available values: ‘true’, ‘false’

    If ‘true’, finds compatible tables in the project.

    If a compatible table is found, the compatible table object information is returned. If no table is found, a new table is created.

    If ‘false’, a new table is created.

  • column_merge_option (enum, optional) –

    Defines a column merge option Available values: ‘reuse_any’, ‘reuse_compatible_data_type’, ‘reuse_matched_data_type’. If ‘TableColumnMergeOption.REUSE_ANY’, updates the column

    data type to use the most recent column definition.

    If ‘TableColumnMergeOption.REUSE_COMPATIBLE_DATA_TYPE’, updates

    the column data type to use the data type with the largest precision or scale.

    If ‘TableColumnMergeOption.REUSE_MATCHED_DATA_TYPE’, renames

    the column in newly added table to allow it to have different data types.

  • table_prefix_option (enum, optional) –

    Define the table prefix Available values: ‘ADD_DEFAULT_PREFIX’, ‘ADD_NAMESPACE’. If ‘TablePrefixOption.ADD_DEFAULT_PREFIX’, applies the default

    prefix setting on warehouse catalog.

    If ‘TablePrefixOption.ADD_NAMESPACE’, create a prefix same

    with namespace.

Returns:

LogicalTable object

Return type:

LogicalTable

Examples

>>> LogicalTable.create(connection,
                        physical_table=PhysicalTable(
                            connection=connection,
                            id="8D67911E11D3E4981000E787EC6DE8A4",
                        ),
                        primary_data_source=SchemaObjectReference(
                            object_id="A23BBC514D336D5B4FCE919FA3",
                            sub_type=ObjectSubType.DB_ROLE
                        ),
                        )
>>> LogicalTable.create(connection,
        physical_table_name="lu_prescriber",
        physical_table_namespace="public",
        primary_data_source=SchemaObjectReference(
                object_id="DAD6CAD6457DAF29E34463961688EA60",
                sub_type=ObjectSubType.DB_ROLE),
        table_name="New Table", table_description="New Description",
        sub_type=ObjectSubType.LOGICAL_TABLE))
classmethod create_alias(connection, id)

Create a new table alias in a specific project.

Parameters:
  • connection (object) – Strategy One connection object returned by connection.Connection().

  • id (str) – Physical table id

Returns:

LogicalTable object

Return type:

type[LogicalTable]

Examples

>>> LogicalTable.create_alias(connection,
                              id="E278D17342991E49710D6F90E2A7BF2C"
                              )
create_shortcut(target_folder_id=None, target_folder_path=None, target_folder=None, project_id=None, project_name=None, project=None, to_dictionary=False)

Create a shortcut to the object.

Parameters:
  • target_folder_id (str, optional) – ID of the target folder. Target folder must be specified, but target_folder_id may be substituted with target_folder_path or target_folder.

  • target_folder_path (str, optional) – Path to the target folder, e.g. ‘/MicroStrategy Tutorial/Public Objects’. May be used instead of target_folder_id.

  • target_folder (Folder, optional) – Target folder object. May be used instead of target_folder_id.

  • project_id (str, optional) – ID of the target project of the new shortcut. The project may be specified by either project_id, project_name or project. If the project is not specified in either way, the project from the connection object is used.

  • project_name (str, optional) – Name of the target project. May be used instead of project_id.

  • project (Project, optional) – Project object specifying the target project. May be used instead of project_id.

  • to_dictionary (bool, optional) – If True, the method will return a dictionary with the shortcut’s properties instead of a Shortcut object. Defaults to False.

Return type:

Shortcut

delete(force=False)

Delete object.

Parameters:
  • force (bool) – If True, then no additional prompt will be shown before deleting object.

  • self (Entity) –

Returns:

True on success. False otherwise.

Return type:

bool

fetch(attr=None)

Fetch the latest object’s state from the I-Server.

Note

This method can overwrite local changes made to the object.

Parameters:
  • attr (Optional[str]) – Attribute name to be fetched. If not specified

  • dictionary. (it will use all getters specified in _API_GETTERS) –

  • None. (Defaults to) –

Raises:

ValueError – If attr cannot be fetched.

Return type:

None

classmethod from_dict(source, connection, to_snake_case=True, with_missing_value=False)
Overrides Dictable.from_dict() to instantiate an object from

a dictionary without calling any additional getters.

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) – A Strategy One Connection object.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case, default 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:

An object of type T.

Return type:

T

get(name)

Get object’s attribute by its name.

list_acl(to_dataframe=False, to_dictionary=False, **filters)

Get Access Control List (ACL) for this object. Optionally filter ACLs by specifying filters.

Parameters:
  • to_dataframe (bool, optional) – if True, return datasets as pandas DataFrame

  • to_dictionary (bool, optional) – if True, return datasets as dicts

  • **filters – Available filter parameters: [deny, type, rights, trustee_id, trustee_name, trustee_type, trustee_subtype, inheritable]

Return type:

DataFrame | list[dict | mstrio.utils.acl.ACE]

Examples

>>> list_acl(deny=True, trustee_name="John")
list_columns(to_dictionary=False)

Lists columns of the table in a dictionary or objects form

Args: to_dictionary (bool): specifies whether to list the columns as

dictionaries or objects. Defaults to False

Returns:

A list of columns as dictionaries or objects, depending on input

Parameters:

to_dictionary (bool) –

list_dependencies(project=None, name=None, pattern=4, domain=2, object_types=None, used_by_recursive=False, root=None, root_path=None, limit=None, offset=None, results_format='LIST', to_dictionary=True, **filters)

List list_dependencies of an object.

Parameters:
  • project (string) – Project object or ID

  • name (string) – Value the search pattern is set to, which will be applied to the names of object types being searched. For example, search for all report objects (type) whose name begins with (pattern) B (name).

  • pattern (integer or enum class object) – 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).

  • domain (integer or enum class object) – Domain where the search will be performed, such as Local or Project. Possible values are available in ENUM mstrio.object_management.SearchDomain. Default value is PROJECT (2).

  • root (string, optional) – Folder ID of the root folder where the search will be performed.

  • root_path (str, optional) –

    Path of the root folder in which the search will be performed. Can be provided as an alternative to root parameter. If both are provided, root is used.

    the path has to be provided in the following format:
    if it’s inside of a project, example:

    /MicroStrategy Tutorial/Public Objects/Metrics

    if it’s a root folder, example:

    /CASTOR_SERVER_CONFIGURATION/Users

  • class (object_types(enum class object or integer or list of enum) – objects or integers): Type(s) of object(s) to be searched, such as Folder, Attribute or User. Possible values available in ENUMs mstrio.types.ObjectTypes and mstrio.types.ObjectSubTypes

  • used_by_recursive (boolean, optional) – Control the Intelligence server to also find objects that are used by the given objects indirectly. Default value is false.

  • results_format (SearchResultsFormat) – either a list or a tree format

  • to_dictionary (bool) – If False returns objects, by default (True) returns dictionaries.

  • limit (int) – limit the number of elements returned. If None (default), all objects are returned.

  • offset (int) – Starting point within the collection of returned results. Used to control paging behavior. Default is 0.

  • **filters – Available filter parameters: [‘id’, ‘name’, ‘description’ ,’date_created’, ‘date_modified’, ‘acg’]

  • self (Entity) –

  • object_types (TypeOrSubtype | None) –

Returns:

list of objects or list of dictionaries

list_dependents(project=None, name=None, pattern=4, domain=2, object_types=None, uses_recursive=False, root=None, root_path=None, limit=None, offset=None, results_format='LIST', to_dictionary=True, **filters)

List dependents of an object.

Parameters:
  • project (string) – Project object or ID

  • name (string) – Value the search pattern is set to, which will be applied to the names of object types being searched. For example, search for all report objects (type) whose name begins with (pattern) B (name).

  • pattern (integer or enum class object) – 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).

  • domain (integer or enum class object) – Domain where the search will be performed, such as Local or Project. Possible values are available in ENUM mstrio.object_management.SearchDomain. Default value is PROJECT (2).

  • root (string, optional) – Folder ID of the root folder where the search will be performed.

  • root_path (str, optional) –

    Path of the root folder in which the search will be performed. Can be provided as an alternative to root parameter. If both are provided, root is used.

    the path has to be provided in the following format:
    if it’s inside of a project, example:

    /MicroStrategy Tutorial/Public Objects/Metrics

    if it’s a root folder, example:

    /CASTOR_SERVER_CONFIGURATION/Users

  • class (object_types(enum class object or integer or list of enum) – objects or integers): Type(s) of object(s) to be searched, such as Folder, Attribute or User. Possible values available in ENUMs mstrio.types.ObjectTypes and mstrio.types.ObjectSubTypes

  • uses_recursive (boolean) – Control the Intelligence server to also find objects that use the given objects indirectly. Default value is false.

  • results_format (SearchResultsFormat) – either a list or a tree format

  • to_dictionary (bool) – If False returns objects, by default (True) returns dictionaries.

  • limit (int) – limit the number of elements returned. If None (default), all objects are returned.

  • offset (int) – Starting point within the collection of returned results. Used to control paging behavior. Default is 0.

  • **filters – Available filter parameters: [‘id’, ‘name’, ‘description’ ,’date_created’, ‘date_modified’, ‘acg’]

  • self (Entity) –

  • object_types (TypeOrSubtype | None) –

Returns:

list of objects or list of dictionaries

list_properties(excluded_properties=None)

Fetches all attributes from the server and converts all properties of the object to a dictionary.

Parameters:

excluded_properties (list[str], optional) – A list of object properties that should be excluded from the dict. Defaults to None.

Returns:

A dictionary which keys are object’s attribute names, and

which values are object’s attribute values.

Return type:

dict

list_translations(languages=None, to_dictionary=False)

Lists translations for the Object.

Parameters:
  • languages (list, optional) –

    list of languages to list the translations for, only translations from these languages will be listed. Languages in the list should be one of the following:

    • lcid attribute of the language

    • ID of the language

    • Language class object

  • to_dictionary (bool, optional) – If True returns dict, by default (False) returns Translation objects

  • self (Entity) –

Returns:

A list of dictionaries representing translations for the Object or a list of Translation Objects.

Return type:

list[’Translation’] | list[dict]

move(folder)

Move the object to a folder on the I-Server.

Parameters:
  • folder (Folder | str) – Destination folder, specified either by id or the Folder object.

  • self (Entity) –

print()

Pretty Print all properties of the object.

Return type:

None

remove_translation(translations)

Removes translations from the Object.

Parameters:
  • translations (list[OperationData]) – list of translations to be added to the Object

  • self (Entity) –

Return type:

None

classmethod to_csv(objects, name, path=None, properties=None)

Exports MSTR objects to a csv file.

Optionally, saves only the object properties specified in the properties parameter.

Parameters:
  • objects (T | list[T]) – List of objects of the same type that

  • exported. (will be) –

  • name (str) – The name of the csv file ending with ‘.csv’

  • path (Optional[str], optional) – A path to the directory where the file will be saved. Defaults to None.

  • properties (Optional[list[str]], optional) – A list of object’s attribute names that should be included in the exported file. Defaults to None.

Raises:
  • TypeError – If objects is not of type T or list of type T

  • objects.

Return type:

None

to_dataframe()

Converts all properties of the object to a dataframe.

Returns:

A DataFrame object containing object properties.

Return type:

DataFrame

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

update_physical_table_structure(col_merge_option=None, ignore_table_prefix=None)
Updates a structure of a physical table upon which the logical table

depends.

Parameters:
  • col_merge_option (enum, optional) –

    Defines a column merge option Available values: ‘reuse_any’, ‘reuse_compatible_data_type’, ‘reuse_matched_data_type’. If ‘TableColumnMergeOption.REUSE_ANY’, updates the column

    data type to use the most recent column definition.

    If ‘TableColumnMergeOption.REUSE_COMPATIBLE_DATA_TYPE’,

    updates the column data type to use the data type with the largest precision or scale.

    If ‘TableColumnMergeOption.REUSE_MATCHED_DATA_TYPE’, renames

    the column in newly added table to allow it to have different data types.

    If this value is not set, use the option that set on DBRole catalog setting.

  • ignore_table_prefix (bool, optional) –

    If true, get all tables under current DB. There are three following situations:

    • If there is only one table that has same name as updated

      table, update table structure using this table.

    • If there is no table that has same name as updated table,

      throw error.

    • If there are multiple tables has same name as updated

      table, throw error.

    If false, remain the current behavior.

    If not set, get the setting value from warehouse catalog. This behavior is same as column merge options.

Return type:

None

Examples

>>> LogicalTable(
>>>     connection, id='FF529E1446BE3DF75ECD4B8E18618747'
>>> ).update_physical_table_structure(
>>>     col_merge_option=TableColumnMergeOption.REUSE_ANY
>>> )
classmethod update_physical_table_structure_for_all_tables(connection, col_merge_option=None, ignore_table_prefix=None)
Updates structure for every table in a project mapped to a

connection.

Parameters:
  • connection (Connection) – Object representation of MSTR Connection.

  • col_merge_option (enum, optional) –

    Defines a column merge option Available values: ‘reuse_any’, ‘reuse_compatible_data_type’, ‘reuse_matched_data_type’. If ‘TableColumnMergeOption.REUSE_ANY’, updates the column

    data type to use the most recent column definition.

    If ‘TableColumnMergeOption.REUSE_COMPATIBLE_DATA_TYPE’,

    updates the column data type to use the data type with the largest precision or scale.

    If ‘TableColumnMergeOption.REUSE_MATCHED_DATA_TYPE’, renames

    the column in newly added table to allow it to have different data types.

    If this value is not set, use the option that set on DBRole catalog setting.

  • ignore_table_prefix (bool, optional) –

    If true, get all tables under current DB. There are three following situations:

    • If there is only one table that has same name as updated

      table, update table structure using this table.

    • If there is no table that has same name as updated table,

      throw error.

    • If there are multiple tables has same name as updated

      table, throw error.

    If false, remain the current behavior.

    If not set, get the setting value from warehouse catalog. This behavior is same as column merge options.

update_properties()

Save compatible local changes of the object attributes to the I-Server. Changes are retrieved from the self._altered_properties dictionary. After the process of update has finished, self._altered_properties is cleared. For this method to work properly, you must override the _alter_properties() method in a subclass.

Raises:

requests.HTTPError – If I-Server raises exception

Return type:

None

mstrio.modeling.schema.table.logical_table.list_changeset_tables(connection, project_id=None, project_name=None, limit=None, changeset_id=None, **filters)
Parameters:
  • connection (Connection) –

  • project_id (str | None) –

  • project_name (str | None) –

  • limit (int | None) –

  • changeset_id (str | None) –

Return type:

list[type[LogicalTable]]

mstrio.modeling.schema.table.logical_table.list_logical_tables(connection, to_dictionary=False, table_type=None, name=None, folder_id=None, folder_path=None, folder_name=None, project_id=None, project_name=None, filters=None, limit=None)
List all logical tables in a project mapped to a specified connection.

Optionally, you can filter by physical table type.

Parameters:
  • connection (Connection) – Object representation of MSTR Connection.

  • name (Optional[str], optional) – Name of a table.

  • project_id (Optional[str], optional) – ID of a project. Defaults to None.

  • project_name (Optional[str], optional) – Name of a project. Defaults to None.

  • folder_id (Optional[str], optional) – ID of a folder in which to look for logical tables. Defaults to None.

  • folder_path (str, optional) –

    Path of the folder in which to look for logical tables. Can be provided as an alternative to folder_id parameter. If both are provided, folder_id is used.

    the path has to be provided in the following format:
    if it’s inside of a project, example:

    /MicroStrategy Tutorial/Public Objects/Metrics

    if it’s a root folder, example:

    /CASTOR_SERVER_CONFIGURATION/Users

  • folder_name (Optional[str], optional) – Name of a folder in which to look for logical tables. Defaults to None.

  • to_dictionary (bool, optional) – If True returns a list of dictionaries. Defaults to False.

  • table_type (PhysicalTableType, optional) – If specified, returns a list of logical tables with physical table with this type.

  • filters (dict | None) –

    dict that specifies filter expressions. Only used if a name, folder_id, folder_name, project_id or project_name are provided. Available filters are: [‘date_created’, ‘date_modified’, ‘version_id’, ‘acg’,

    ’primary_locale’, ‘sub_type’, ‘name’, ‘id’]

  • limit (int | None) – limit the number of elements returned. If None (default), all objects are returned.

Returns:

A list of LogicalTable objects

or dictionaries representing logical tables.

Return type:

list[”LogicalTable”] | list[dict]