Skip to content

Commit

Permalink
Merge branch 'm-kovalsky/issue290'
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kovalsky committed Nov 20, 2024
2 parents e7fd904 + 53bcbe3 commit 6345d1e
Showing 1 changed file with 49 additions and 29 deletions.
78 changes: 49 additions & 29 deletions src/sempy_labs/_generate_semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,60 @@ def create_blank_semantic_model(
f"{icons.red_dot} Compatiblity level must be at least {min_compat}."
)

tmsl = f"""
{{
"createOrReplace": {{
"object": {{
"database": '{dataset}'
}},
"database": {{
"name": '{dataset}',
"compatibilityLevel": {compatibility_level},
"model": {{
"cultures": [
{{
"name": "en-US",
"linguisticMetadata": {{
"content": {{
"Version": "1.0.0",
"Language": "en-US"
}},
"contentType": "json"
# If the model does not exist
if len(dfD_filt) == 0:
tmsl = f"""
{{
"createOrReplace": {{
"object": {{
"database": '{dataset}'
}},
"database": {{
"name": '{dataset}',
"compatibilityLevel": {compatibility_level},
"model": {{
"cultures": [
{{
"name": "en-US",
"linguisticMetadata": {{
"content": {{
"Version": "1.0.0",
"Language": "en-US"
}},
"contentType": "json"
}}
}}
],
"collation": "Latin1_General_100_BIN2_UTF8",
"dataAccessOptions": {{
"legacyRedirects": true,
"returnErrorValuesAsNull": true,
}},
"defaultPowerBIDataSourceVersion": "powerBI_V3",
"sourceQueryCulture": "en-US",
}}
],
"collation": "Latin1_General_100_BIN2_UTF8",
"dataAccessOptions": {{
"legacyRedirects": true,
"returnErrorValuesAsNull": true,
}},
"defaultPowerBIDataSourceVersion": "powerBI_V3",
"sourceQueryCulture": "en-US",
}}
}}
}}
}}
"""
"""
else:
tmsl = f"""
{{
"createOrReplace": {{
"object": {{
"database": '{dataset}'
}},
"database": {{
"name": '{dataset}',
"compatibilityLevel": {compatibility_level},
"model": {{
"culture": "en-US",
"defaultPowerBIDataSourceVersion": "powerBI_V3"
}}
}}
}}
}}
"""

fabric.execute_tmsl(script=tmsl, workspace=workspace)

Expand Down

0 comments on commit 6345d1e

Please sign in to comment.