Skip to content

M kovalsky/snowflake - #1333

Open
Michael Kovalsky (m-kovalsky) wants to merge 8 commits into
microsoft:mainfrom
m-kovalsky:m-kovalsky/snowflake
Open

Michael Kovalsky (m-kovalsky) wants to merge 8 commits into
microsoft:mainfrom
m-kovalsky:m-kovalsky/snowflake

Conversation

@m-kovalsky

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI lite review requested due to automatic review settings September 10, 2026 06:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Several public API surfaces have fixable contract/maintainability issues (return type annotations, redundant logic) and the large YAML assets under src/ risk shipping unnecessary package bloat.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds Snowflake semantic-view support by converting Snowflake Semantic View YAML into the project’s model_map format, generating a Direct Lake Model.bim, and expanding the SQL→DAX translator to cover more Snowflake-style scalar functions while safely falling back to BLANK() for unsupported/unresolvable expressions.

Changes:

  • Added Snowflake semantic view conversion pipeline (convert_from_snowflake) plus Snowflake REST helpers to enumerate base-table columns.
  • Introduced convert_model_map_to_bim to emit Direct Lake TMSL (Model.bim) from a model_map and exported it via sempy_labs.semantic_model.
  • Enhanced convert_sql_to_dax with more scalar/function translations and stricter “untranslatable → BLANK()” behavior; added tests and updated the SQL→DAX skill guide.
File summaries
File Description
tests/test_sql_to_dax.py Adds unit tests for new SQL→DAX translations and BLANK() fallback behavior.
tests/test_convert_model_map.py Adds unit tests validating model_map → Model.bim output structure and annotations.
src/sempy_labs/semantic_model/snowflakeSM.yaml Adds a large example Snowflake semantic view YAML.
src/sempy_labs/semantic_model/snowflake.yaml Adds a template/spec-style Snowflake semantic view YAML skeleton.
src/sempy_labs/semantic_model/_snowflake.py Implements YAML→model_map conversion + optional semantic model creation from BIM.
src/sempy_labs/semantic_model/_helper.py Extends SQL→DAX translation and standardizes unsupported/unparseable handling to BLANK().
src/sempy_labs/semantic_model/_convert_model_map.py Introduces conversion from model_map to Direct Lake TMSL (Model.bim).
src/sempy_labs/semantic_model/init.py Exports convert_model_map_to_bim from the semantic_model package.
src/sempy_labs/_snowflake.py Adds Snowflake API wrappers for listing tables/columns.
.claude/skills/sql_to_dax/SKILL.md Documents the new SQL→DAX translation rules and edge cases.
Review details

Suppressed comments (1)

src/sempy_labs/_snowflake.py:75

  • The function returns response.json() when return_dataframe=False, but the return type is annotated as pd.DataFrame. Please update the annotation to reflect the JSON return option for a stable public API contract.
def list_snowflake_columns(
    account: str,
    token: str,
    database: str,
    schema: str,
    table: str,
    return_dataframe: bool = True,
) -> pd.DataFrame:

  • Files reviewed: 10/10 changed files
  • Comments generated: 7
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +16 to +23
def list_snowflake_tables(
account: str,
token: str,
database: str,
schema: str,
table: Optional[str] = None,
return_dataframe: bool = True,
) -> pd.DataFrame:
Comment on lines +60 to +63
if rows:
df = pd.DataFrame(rows, columns=columns.keys())

return df
Comment on lines +125 to +130
@log
def convert_from_snowflake(
yaml_file: str,
account: str,
token: str,
source_item: str | UUID,
Comment on lines +1 to +10
# Name and description of the semantic view.
name: <name>
description: <string>

# Logical table-level concepts
# A semantic view can contain one or more logical tables.
tables:
# A logical table on top of a base table.
- name: <name>
description: <string>
Comment on lines +1 to +6
name: MKVIEW
description: >-
Store-channel retail analytics semantic view over the DEMO.STORE schema.
Covers store sales, store returns, customers, stores and the shared calendar,
including profitability, discount, promotion and return-behavior metrics.
tables:
Comment on lines +137 to +139
"""
Converts a Snowflake semantic view YAML definition into the a Power BI semantic model in Direct Lake mode.

Comment on lines +177 to +181
if hasattr(yaml_file, "read"):
data = yaml.safe_load(yaml_file)
else:
data = yaml.safe_load(yaml_file)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants