Skip to content

feat: dbt-managed Snowflake semantic view for prospect funnel#6

Open
benjamin-shi-tql wants to merge 3 commits into
mainfrom
feat/prospect-snowflake-semantic-view
Open

feat: dbt-managed Snowflake semantic view for prospect funnel#6
benjamin-shi-tql wants to merge 3 commits into
mainfrom
feat/prospect-snowflake-semantic-view

Conversation

@benjamin-shi-tql

Copy link
Copy Markdown
Collaborator

Summary

Deploys the prospect funnel metrics as a native Snowflake SEMANTIC VIEW (YARDI.MARTS.SEM_PROSPECT_FUNNEL), with the DDL controlled from this dbt repo. This is the Snowflake-native alternative to the MetricFlow YAML approach (PR #5) — the metrics become a real Snowflake object consumable by Cortex Analyst and SEMANTIC_VIEW(...) queries.

Pattern: control model + post-hook macro

dbt has no native SEMANTIC VIEW materialization, so:

  • models/semantic_views/sem_prospect_funnel.sql — one-row anchor model that ref('fct_prospects') (forces build order) and carries a post_hook.
  • macros/create_prospect_semantic_view.sql — holds the CREATE OR REPLACE SEMANTIC VIEW DDL; runs on every dbt run.
  • models/semantic_views/_sem_prospect_funnel.yml — docs/tests.

Semantic view contents

  • TABLES: prospects over fct_prospects, PK prospect_id, synonyms.
  • FACTS: toured / applied / approved / leased flags + days_to_apply / days_to_movein + desired_rent.
  • DIMENSIONS: prospect_status, lead_source, desired_bedrooms, leasing_agent, property_name/region/fund, contact_date/month (with synonyms).
  • METRICS: total_prospects, leased_prospects, tour_rate, application_rate, approval_rate, lead_to_lease_conversion, avg_days_to_apply, avg_days_to_movein, avg_desired_rent.

Validation (live Yardi (Demo))

  • DDL grammar confirmed against Snowflake CREATE SEMANTIC VIEW docs.
  • Connector is read-only, so the object is created by dbt run; metric math validated by reproducing every metric on source data: 150 prospects, 19 leased, tour_rate 0.613, application_rate 0.547, approval_rate 0.415, lead_to_lease_conversion 0.127, avg_days_to_apply 7.4, avg_days_to_movein 34.1, avg_desired_rent 2221.

Consuming

SELECT * FROM SEMANTIC_VIEW(
  YARDI.MARTS.SEM_PROSPECT_FUNNEL
  DIMENSIONS lead_source
  METRICS lead_to_lease_conversion, total_prospects
) ORDER BY lead_to_lease_conversion DESC;

Depends on fct_prospects (PR #4). Supersedes the MetricFlow YAML in PR #5 if you prefer the Snowflake-native route.

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.

1 participant