bytebase/bytebase · error

unsupported statement in query span extractor: %T

Error message

unsupported statement in query span extractor: %T

What it means

extractOmniStmt is the generic statement dispatch for the span extractor and only accepts *oracleast.SelectStmt; any other StmtNode type hits this error naming the concrete type. It signals an internal capability gap rather than a syntax problem — the SQL parsed fine.

Source

Thrown at backend/plugin/parser/plsql/query_span_extractor_omni.go:434

			columns = next
		}
		return &base.PseudoTable{Name: name, Columns: columns}, nil
	}

	child := q.clone()
	tableSource, err := child.extractOmniStmt(cte.Query)
	if err != nil {
		return nil, err
	}
	columns := cloneQuerySpanResults(tableSource.GetQuerySpanResult())
	applyOmniColumnAliases(columns, columnNames)
	return &base.PseudoTable{Name: name, Columns: columns}, nil
}

func (q *omniQuerySpanExtractor) extractOmniStmt(stmt oracleast.StmtNode) (base.TableSource, error) {
	selectStmt, ok := stmt.(*oracleast.SelectStmt)
	if !ok {
		return nil, errors.Errorf("unsupported statement in query span extractor: %T", stmt)
	}
	return q.extractOmniSelect(selectStmt)
}

func (q *omniQuerySpanExtractor) extractOmniTargetList(list *oracleast.List) ([]base.QuerySpanResult, error) {
	if list == nil || list.Len() == 0 {
		return q.expandOmniAsterisk("", "")
	}

	var results []base.QuerySpanResult
	for _, node := range listItems(list) {
		target, ok := node.(*oracleast.ResTarget)
		if !ok || target.Expr == nil {
			continue
		}
		if isOmniStar(target.Expr) {
			expanded, err := q.expandOmniAsterisk("", "")
			if err != nil {

View on GitHub (pinned to 1870550677)

Solutions

  1. Add a case for the offending AST type in extractOmniStmt (or unwrap it to its inner SelectStmt)
  2. Confirm the construct should really be a SELECT; if it is a new wrapper node, extend the extractor to dereference it
  3. Report/fix the grammar-to-extractor mismatch in the omni parser package

Example fix

// before
selectStmt, ok := stmt.(*oracleast.SelectStmt)
if !ok { return nil, errors.Errorf(...) }
// after
switch s := stmt.(type) {
case *oracleast.SelectStmt:
    return q.extractOmniSelect(s)
case *oracleast.SubqueryWrapper:
    return q.extractOmniStmt(s.Stmt)
default:
    return nil, errors.Errorf("unsupported statement in query span extractor: %T", stmt)
}
Defensive patterns

Strategy: type-guard

Validate before calling

list, _ := ParsePLSQLOmni(stmt)
raw := list.Items[0].(*oracleast.RawStmt)
if _, ok := raw.Stmt.(*oracleast.SelectStmt); !ok { /* skip extraction */ }

Type guard

func asSelectStmt(node oracleast.StmtNode) (*oracleast.SelectStmt, bool) {
    s, ok := node.(*oracleast.SelectStmt)
    return s, ok
}

Try / catch

src, err := extractor.GetQuerySpan(ctx, stmt)
if err != nil && strings.Contains(err.Error(), "unsupported statement in query span extractor") {
    return nil, errUnsupportedStatementType
}

Prevention

When it happens

Trigger: A subquery/statement node that is not a SelectStmt (e.g. another statement wrapper type) reaches extractOmniStmt during span extraction, typically from CTE bodies, derived tables, or sub-selects parsed into a different node type.

Common situations: Grammar changes reclassifying constructs into new AST node types without updating the extractor; nested DML-with-RETURNING or cursor expressions hitting the extractor; callers passing whole scripts whose first node is not a plain SELECT.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06). Data as JSON: /api/errors/3edb52bada81843c. Report an issue: GitHub.