Skip to content

Metric validation silently skips column resolution for namespaced references #1960

@shangyian

Description

@shangyian

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:

  1. Struct field: a is a column of struct type on the source table, and b is one of its fields.
  2. Table alias: a is an alias in the metric SQL (e.g. FROM default.some_node a) and label is a column on it.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions