Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
A label is the name you gave a vertex or edge in the graph definition, such as individual or orderProduct. A label expression lets you combine those names.
Write the expression after the colon: (v:<label_expression>) for an object, -[e:<label_expression>]-> for a connection.
Operators
| Operator | Name | Meaning | Ecommerce example |
|---|---|---|---|
:Label |
Label | Has this label | (i:individual) |
& |
Conjunction | Has both labels | (i:individual & loyaltyMember) |
| |
Disjunction | Has either label | (item:individual | product) |
! |
Negation | Doesn't have this label | (v:!loyaltyMember) |
% |
Wildcard | Any vertex or any edge | (item:%) |
A bare (v) is the same as (v:%).
Operators bind in this order: !, then &, then |. So individual | product & featured means individual | (product & featured). And !individual & product means (!individual) & product. Use parentheses to override the default. To negate a negation, parenthesize the inner expression: !(!individual).
WITH pg AS PROPERTY GRAPH (...)
SELECT * FROM GRAPH_TABLE(pg
MATCH (item:(individual | product) & featured)
COLUMNS (item.name)
) AS gt;
That matches a featured product, not a featured customer, unless you also gave customers the featured label.
Extra Labels for These Examples
The commerce graph in Defining a Property Graph has one label per table. Use this copy of that definition, with extra labels, for the examples on this page.
Don't put loyaltyMember on every customer if you want individual & !loyaltyMember to return rows. This definition uses a second Individual vertex table, otherCustomers, for customers who aren't loyalty members. Filter each Individual table so the same customer isn't in both, or every customer still matches loyaltyMember through loyaltyCustomers.
WITH pg AS PROPERTY GRAPH (
VERTEX TABLES (
(SELECT * FROM ssot__Individual__dlm WHERE ssot__Id__c IN ('I-100'))
AS loyaltyCustomers KEY (ssot__Id__c)
LABEL individual PROPERTIES (
ssot__Id__c AS individualId,
ssot__FirstName__c AS name
)
LABEL loyaltyMember,
(SELECT * FROM ssot__Individual__dlm WHERE ssot__Id__c NOT IN ('I-100'))
AS otherCustomers KEY (ssot__Id__c)
LABEL individual PROPERTIES (
ssot__Id__c AS individualId,
ssot__FirstName__c AS name
),
ssot__SalesOrder__dlm AS orders KEY (ssot__Id__c)
LABEL salesOrder PROPERTIES (
ssot__Id__c AS orderId,
ssot__Name__c AS name
),
ssot__GoodsProduct__dlm AS products KEY (ssot__Id__c)
LABEL product PROPERTIES (
ssot__Id__c AS productId,
ssot__Name__c AS name
)
LABEL featured
LABEL seasonal
)
EDGE TABLES (
ssot__SalesOrder__dlm AS loyaltyOrders KEY (ssot__Id__c)
SOURCE KEY (ssot__SoldToCustomerId__c) REFERENCES loyaltyCustomers
DESTINATION KEY (ssot__Id__c) REFERENCES orders
LABEL customerOrder PROPERTIES (
ssot__CreatedDate__c AS createdDate
),
ssot__SalesOrder__dlm AS otherOrders KEY (ssot__Id__c)
SOURCE KEY (ssot__SoldToCustomerId__c) REFERENCES otherCustomers
DESTINATION KEY (ssot__Id__c) REFERENCES orders
LABEL customerOrder PROPERTIES (
ssot__CreatedDate__c AS createdDate
),
ssot__SalesOrderProduct__dlm AS orderProducts KEY (ssot__Id__c)
SOURCE KEY (ssot__SalesOrderId__c) REFERENCES orders
DESTINATION KEY (ssot__ProductId__c) REFERENCES products
LABEL orderProduct
LABEL promotionOrderProduct PROPERTIES (
ssot__CreatedDate__c AS createdDate,
ssot__OrderedQuantity__c AS quantity
)
)
)
The two Individual subqueries keep loyalty members and other customers in separate vertex tables. The two customerOrder edge tables give both groups a path to orders.
Customers Who Are Loyalty Members
WITH pg AS PROPERTY GRAPH (...)
SELECT * FROM GRAPH_TABLE(pg
MATCH (i:individual & loyaltyMember)
COLUMNS (i.individualId, i.name)
) AS gt;
Customers or Products
WITH pg AS PROPERTY GRAPH (...)
SELECT * FROM GRAPH_TABLE(pg
MATCH (item:individual | product)
COLUMNS (item.name)
) AS gt;
Customers Who Aren't Loyalty Members
WITH pg AS PROPERTY GRAPH (...)
SELECT * FROM GRAPH_TABLE(pg
MATCH (i:individual & !loyaltyMember)
COLUMNS (i.name)
) AS gt;
Regular or Promotion Line Items
WITH pg AS PROPERTY GRAPH (...)
SELECT * FROM GRAPH_TABLE(pg
MATCH (i:individual)-[:customerOrder]->(:salesOrder)
-[line:orderProduct | promotionOrderProduct]->(product:product)
COLUMNS (i.individualId, product.productId, line.createdDate, line.quantity)
) AS gt;
WITH pg AS PROPERTY GRAPH (...)
SELECT * FROM GRAPH_TABLE(pg
MATCH (i:individual)-[:customerOrder]->(:salesOrder)
-[line:orderProduct & promotionOrderProduct]->(product:product)
COLUMNS (i.individualId, product.productId, line.createdDate, line.quantity)
) AS gt;
Featured or Seasonal Products
Using the same variable twice keeps only the records that match both patterns.
WITH pg AS PROPERTY GRAPH (...)
SELECT * FROM GRAPH_TABLE(pg
MATCH (item:product), (item:featured | seasonal)
COLUMNS (item.productId, item.name)
) AS gt;
That is the same as MATCH (item:product & (featured | seasonal)).