Aliasing table names in Snowflake

After copying data overnight from SQL Server to Snowflake, I wanted to recreate an SSRS report in Data Studio.

Unfortunately the copied over tables all had ‘STG_’ appended to the start of their names (e.g. STG_Customers).

There is nothing like ‘Synonym’ built into Snowflake yet, and I really didn’t want to go through the legacy query adding ‘STG_’ to the beginning of each and every table mentioned.

My solution was to create individual Views as table aliases. Views in Snowflake are blindingly fast. I used an RBAR loop to automate the process.

My final Task was to schedule the script to run every night. This lets it scale by picking up any new tables.

-- Snowflake table aliasing

-- schedule
CREATE OR REPLACE TASK reports.task_sync_alias
WAREHOUSE = compute_wh -- default for this demo
SCHEDULE = 'using cron 0 5 * * * UTC' -- every 5am
AS  
  -- cursor
  DECLARE
    var_table_name STRING;
    var_view_name STRING;
    var_cmd STRING;

  stg_cursor CURSOR FOR
    SELECT table_name
    FROM INFORMATION_SCHEMA.TABLES
    WHERE table_name like 'STG_%'
    AND table_schema = 'STAGING'
    AND table_type = 'BASE TABLE';

  -- loop 
  BEGIN
    FOR RECORD IN stg_cursor DO
      var_table_name := RECORD.table_name;
      var_view_name := SUBSTR(var_table_name, 5);
      var_cmd := 
        'CREATE OR REPLACE VIEW ' || var_view_name ||
        ' AS SELECT * FROM STAGING.' || var_table_name;
      EXECUTE IMMEDIATE: var_cmd;
    END FOR;
  END;

-- enable schedule
ALTER TASK reports.task_sync_alias resume;

Dynamic links in Data Studio

In an snowflake admin report I wanted a list of analytical reports that I could click on to open each individually.

With a data source containing two columns ‘Report_Name’ and ‘Report_URL’ I added a table to the report surface.

Within the table properties I removed the default metric (Report_URL), and selected ‘add dimension’ then ‘add calculated field’.

For display-name I typed ‘Report Name’ and for formula I typed ‘HYPERLINK(Report_URL, Report_name)’.

When I clicked Apply the data-type property changed from Text to Hyperlink. I waited until the report communications with the data-source had finished, then I clicked the report surface to remove the properties box.

Finally to clean up, I removed the default measure (Report_Name) and waited, then I changed the Sort order to ‘Report Name’ descending (and waited), then in the style tab I deselected ‘Row Numbers’.

“Data Engineering” in 2025

I’m a big fan of Airflow now, and can’t wait for my next opportunity to use it. The user interface is just – delicious. Airflow orchestrates python scripts. This project was copying data nightly from SQL Server into Snowflake.

This post started out as “Airflow Integration” and was going to start with setting up Airflow, then a breakdown of the python into sections, before ending with alerts, and maybe I’ll still do that post … but when I started I realised my main “take away” was … A.I.

Sure I’ve used python before but this time seemed different. The code feels 100% mine – which is odd – as I didn’t type a single word of it.

Staying in front of the “amalgamation engine” can be tricky, and many times I found myself wheeling away from rabbit holes or just shouting “halt!”.

“Co-pilot” is absolutely the right relationship to maintain. As soon as I started asking open questions like “well, what do you think?” it was time to call it a day.

My development experience helped. I found knowing how to get past roadblocks, the necessity of frequent testing, when to be pragmatic instead of perfect, and when to step back to the last working version were – pure gold.

Ultimately, I feel vibe coding shines for rapid prototyping or as an easy entry point for non-coders. Although subsequent debugging was painful, it remains a truly fascinating new tool.

Snowflake Glossary

Unload = Export

Data Warehouse = Snowflake is a cloud based data storage repository, optimised for analysis.

Warehouse = A virtual server. For CPU, memory, etc

Snowpark = Development libraries. Often used when building pipelines.

Snowsight = The Gui

Columnar = internal data storage method, where each data column has its own table.

Account = Typically, company membership credentials.

Schema = Catalogue of related items within a database.

Tag = Alias

Time travel = Retrieve ‘old’ data from up to 90 days ago.

Multi cluster = More than one warehouse linked to the same data.