Skip to content

Commit

Permalink
the TOM import was not in all of the necessary functions. fixed a bug…
Browse files Browse the repository at this point in the history
… in the add_field_parameter function.
  • Loading branch information
m-kovalsky committed Jun 14, 2024
1 parent 94ce4f0 commit 4b833b1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/sempy_labs/_tom.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
class TOMWrapper:
"""
Convenience wrapper around the TOM object model for a semantic model. Always use connect_semantic_model function to make sure the TOM object is initialized correctly.
`XMLA read/write endpoints <https://learn.microsoft.com/power-bi/enterprise/service-premium-connect-tools#to-enable-read-write-for-a-premium-capacity>`_ must be enabled if setting the readonly parameter to False.
"""

_dataset: str
Expand Down Expand Up @@ -646,7 +648,7 @@ def add_hierarchy(
Name of the hierarchy.
columns : List[str]
Names of the columns to use within the hierarchy.
`levels <https://learn.microsoft.com/dotnet/api/microsoft.analysisservices.level?view=analysisservices-dotnet>`_ : List[str], default=None
levels : List[str], default=None
Names of the levels to use within the hierarhcy (instead of the column names).
hierarchy_description : str, default=None
A description of the hierarchy.
Expand Down Expand Up @@ -962,7 +964,7 @@ def add_entity_partition(
if expression is None:
ep.ExpressionSource = self._model.Expressions["DatabaseQuery"]
else:
ep.ExpressionSource = expression
ep.ExpressionSource = self.model.Expressions[expression]
p = TOM.Partition()
p.Name = table_name
p.Source = ep
Expand Down Expand Up @@ -2547,6 +2549,8 @@ def add_field_parameter(self, table_name: str, objects: List[str]):
Measures may be formatted as '[Measure Name]' or 'Measure Name'.
"""

import Microsoft.AnalysisServices.Tabular as TOM

if isinstance(objects, str):
print(f"{icons.red_dot} The 'objects' parameter must be a list of columns/measures.")
return
Expand Down Expand Up @@ -2627,7 +2631,6 @@ def add_field_parameter(self, table_name: str, objects: List[str]):
)

self.set_extended_property(
self=self,
object=self._model.Tables[table_name].Columns[col2],
extended_property_type="Json",
name="ParameterMetadata",
Expand Down Expand Up @@ -3165,6 +3168,8 @@ def show_incremental_refresh_policy(self, table_name: str):
Name of the table.
"""

import Microsoft.AnalysisServices.Tabular as TOM

rp = self._model.Tables[table_name].RefreshPolicy

if rp is None:
Expand Down Expand Up @@ -3613,6 +3618,7 @@ def set_data_type(self, table_name: str, column_name: str, value: str):
The data type.
`Data type valid values <https://learn.microsoft.com/dotnet/api/microsoft.analysisservices.datatype?view=analysisservices-dotnet>`_
"""
import Microsoft.AnalysisServices.Tabular as TOM
import System

values = [
Expand Down

0 comments on commit 4b833b1

Please sign in to comment.