When creating a metric node, the validation step in validate_node_data skips validation of all columns that have a namespace (i.e. any table.column or alias.column reference), on the assumption that they are dimension references that will be validated at compile time.
This means a metric like:
SELECT ANY_VALUE(IF(a.b IS NOT NULL, 1, 2)) FROM default.some_node
passes validation even though a.b is invalid (a is not a table alias, not a struct column on measures_f, and not a dimension node).
There are three valid cases a namespaced reference can legitimately exist:
- Struct field:
a is a column of struct type on the source table, and b is one of its fields.
- Table alias:
a is an alias in the metric SQL (e.g. FROM default.some_node a) and label is a column on it.
- Dimension node:
a is a DJ dimension node and b is an attribute, resolved at compile time.
The current code defers all three to compile time, but cases 1 and 2 can and should be validated eagerly.
When creating a metric node, the validation step in
validate_node_dataskips validation of all columns that have a namespace (i.e. anytable.columnoralias.columnreference), on the assumption that they are dimension references that will be validated at compile time.This means a metric like:
passes validation even though
a.bis invalid (ais not a table alias, not a struct column on measures_f, and not a dimension node).There are three valid cases a namespaced reference can legitimately exist:
ais a column of struct type on the source table, andbis one of its fields.ais an alias in the metric SQL (e.g.FROM default.some_node a) and label is a column on it.ais a DJ dimension node andbis an attribute, resolved at compile time.The current code defers all three to compile time, but cases 1 and 2 can and should be validated eagerly.