Forum Discussion

sresan477's avatar
sresan477
Frequent Visitor
1 year ago
Solved

Load data from snowflake into Semantic Model using TOM and C#

I am trying to load data into a semantic model in C# using the TOM model in import mode. I have tried these 2 approaches so far and both have resulted in the table being created with no data: 1. O...
  • sresan477's avatar
    1 year ago

    Wanted to update the thread with a solution that worked for me. I followed this guide: https://www.azureguru.net/autogenerate-semantic-model-using-tabular-object-model-for-a-fabric-workspace
    which was helpful in resolving my problem. 

    These are the M expressions I used for Snowflake and Databricks in conjunction with the above article:

    // your inputs
    string workspaceHost = "host.azuredatabricks.net"; // replace accordingly if google or aws
    string warehouseId   = "/sql/1.0/warehouses/warehouse_ID";
    string catalogName   = "health_care_sanity_payment";
    string databaseName  = "payment_info";
    string schemaName    = "payment_info";
    string tableName     = "payments";
    
    // build the M expression with interpolation
    string mExpression = $@"
    let
        host      = ""{workspaceHost}"",
        warehouse = ""{warehouseId}"",
        catalog   = ""{catalogName}"",
        database  = ""{databaseName}"",
        schema    = ""{schemaName}"",
        table     = ""{tableName}"",
    
        Source       = Databricks.Catalogs(host, warehouse, [Catalog = catalog, Database = database]),
        payment_data = Source{{[Item=table, Schema=schema, Catalog=catalog]}}[Data]
    in
        payment_data";
    // your inputs
    string account   = "your_account_identifier.region.snowflakecomputing.com";
    string warehouse = "YOUR_WAREHOUSE_NAME";
    string database  = "YOUR_DATABASE_NAME";
    string schema    = "YOUR_SCHEMA_NAME";
    string table     = "YOUR_TABLE_NAME";
    
    string mExpression = $@"
    let
        Source             = Snowflake.Databases(""{account}"", ""{warehouse}"", [Implementation = ""2.0""]),
        {database}_Database = Source{{[Name = ""{database}"", Kind = ""Database""]}}[Data],
        {schema}_Schema     = {database}_Database{{[Name = ""{schema}"", Kind = ""Schema""]}}[Data],
        {table}_Table       = {schema}_Schema{{[Name = ""{table}"", Kind = ""Table""]}}[Data]
    in
        {table}_Table";