Merge Statements
Merge Statements
Merge statements unify concepts from different sources, allowing them to be queried together. This is useful when the same logical concept exists in multiple namespaces.
Syntax
merge_statement: "merge" WILDCARD_IDENTIFIER "into" SHORTHAND_MODIFIER? WILDCARD_IDENTIFIER
Basic Merge
Merge one concept into another:
import sales.customer as sales_customer;
import support.customer as support_customer;
merge sales_customer.id into support_customer.id;
After merging, queries can join data across both sources using the merged concept.
Wildcard Merge
Use wildcards to merge multiple concepts at once:
merge sales.* into main.*;
This merges all matching concepts from the sales namespace into the main namespace.
Partial Modifier
Use ~ to mark the merge as partial (the merged concept has a subset of values of the full concept).
Tips
This is very common for blending into a date dimension, for example - you may not have an order on every day.
merge sales.customer.id into ~main.customer.id;
Example
import web_orders as web;
import store_orders as store;
# Merge order concepts so we can query across channels
merge web.order.id into store.order.id;
merge web.order.date into store.order.date;
merge web.order.total into store.order.total;
select
store.order.date,
sum(store.order.total) -> combined_sales
;
