SigNoz/signoz · error

CodeUnsupported

CodeUnsupported

Error message

reserved keyword found in select clause

What it means

The ClickHouse origin-field parser walks the SELECT expressions of a query and rejects the query if it contains reserved SQL keywords. This is a guard against queries whose select clause cannot be safely decomposed for origin-field extraction (used to attribute metrics to their source column).

Solutions

  1. Rewrite the select clause to avoid the reserved keyword (rename aliases, restructure expressions)
  2. Check the parser's reserved keyword list and remove/extend it if the keyword is safe for extraction
  3. Fall back to manual origin-field specification instead of automatic extraction

Example fix

// before
SELECT count() AS group FROM samples

// after
SELECT count() AS sample_count FROM samples
Defensive patterns

Strategy: validation

Validate before calling

// lint queries before passing to the extractor
func safeForOriginExtraction(q string) bool {
    upper := strings.ToUpper(q)
    for _, kw := range []string{"GROUP", "ORDER", "HAVING"} { // per parser's list
        if strings.Contains(upper, kw) {
            return false
        }
    }
    return true
}

Try / catch

field, err := extractCHOriginFieldFromQuery(q)
if err != nil && errors.Is(err, errUnsupported) {
    // fall back to manual origin field
}

Prevention

When it happens

Trigger: Calling extractCHOriginFieldFromQuery (query filter extraction pipeline) with a query whose SELECT clause uses reserved keywords such as functions or clauses the extractor does not support.

Common situations: Writing custom ClickHouse queries with window functions, CTE keywords, aliases colliding with reserved words, or upgrading the parser so more keywords become rejected.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/bbd1ffa216ddc1d2. Report an issue: GitHub.

Appendix: source

Thrown at pkg/queryparser/queryfilterextractor/clickhouse_originparser.go:175

					for _, arg := range funcExpr.Params.Items.Items {
						if containsJSONExtractFunction(arg) {
							hasExcludedExpressions = true
							return false
						}
					}
				}
			}
		}
		if _, ok := node.(*parser.CaseExpr); ok {
			hasExcludedExpressions = true
			return false
		}
		return true
	})

	// If the expression contains reserved keywords, return error
	if hasReservedKeyword {
		return "", errors.New(errors.TypeUnsupported, errors.CodeUnsupported, "reserved keyword found in select clause")
	}

	// If the expression contains excluded expressions, return empty string
	if hasExcludedExpressions {
		return "", nil
	}

	// Extract all column names from the expression
	columns := extractColumns(expr)

	// If we found exactly one unique column, return it
	if len(columns) == 1 {
		return columns[0], nil
	}

	// Multiple columns or no columns - return empty string
	return "", nil
}

View on GitHub (pinned to 5069bf80b0)