Skip to content

Conversation

@Synohara
Copy link

@Synohara Synohara commented Dec 3, 2025

Summary

When using bind variables with identifier(?) in SEMANTIC_VIEW queries, Snowflake returns numeric column names (e.g., "2") instead of the actual dimension/metric/fact names. This causes WHERE and ORDER BY clauses to fail because they reference non-existent column names.

Changes

  • Add AS {expr.name} alias to each identifier in DIMENSIONS, METRICS, and FACTS clauses
  • This preserves column names while maintaining the security benefits of using bind variables

Example

Before (Error):

SELECT * FROM SEMANTIC_VIEW (identifier(?) DIMENSIONS identifier(?))
WHERE column_name = 'value'
-- Error: invalid identifier 'column_name'
-- Result columns have numeric names like "2" instead of actual names

After (Success):

SELECT * FROM SEMANTIC_VIEW (identifier(?) DIMENSIONS identifier(?) AS column_name)
WHERE column_name = 'value'
-- ✓ Works correctly
-- Result columns have proper names

When using bind variables with identifier(?) in SEMANTIC_VIEW queries,
Snowflake returns numeric column names instead of the actual dimension/
metric/fact names. This makes WHERE and ORDER BY clauses fail because
they reference non-existent column names.

This fix adds AS alias to each identifier:
- identifier(?) AS {expr.name}

This preserves the column names while maintaining the security benefits
of using bind variables for the identifier values.
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.

2 participants