t8y2/dbx · error

SQL is required

Error message

SQL is required

What it means

executeQuery is the central query entry point. It trims the provided SQL and rejects empty statements with this error before acquiring the connection, applying default fetch size and max rows. This prevents issuing meaningless empty statements to HiveServer2.

Source

Thrown at agents/drivers/argo-go/query.go:33

func (server *server) validateConnection() error {
	connection, err := server.requireConnection()
	if err != nil {
		return err
	}
	ctx, cancel := context.WithTimeout(context.Background(), server.config.ConnectTimeout)
	defer cancel()
	return connection.PingContext(ctx)
}

func (server *server) executeQuery(options queryOptions) (queryResult, error) {
	started := time.Now()
	if options.FetchSize <= 0 {
		options.FetchSize = server.effectiveFetchSize()
	}
	sqlText := trimStatementSQL(options.SQL)
	if sqlText == "" {
		return queryResult{}, errors.New("SQL is required")
	}
	maxRows := options.MaxRows
	if maxRows <= 0 {
		maxRows = defaultMaxRows
	}
	connection, err := server.requireConnection()
	if err != nil {
		return queryResult{}, err
	}

	ctx, cancel := queryContext(options.TimeoutSecs)
	server.setActiveOperation(cancel)
	defer server.clearActiveOperation(cancel)
	if err := server.applySchemaContext(ctx, connection, effectiveSchema(options)); err != nil {
		return queryResult{}, err
	}
	rows, affected, hasResultSet, err := executeHiveStatement(ctx, connection, sqlText, options.FetchSize)
	if err != nil {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Set queryOptions.SQL to a non-empty statement before calling executeQuery
  2. Validate the SQL field on the client/request layer before dispatch
  3. Check that SQL-building helpers (e.g. SHOW queries with interpolated names) receive non-empty inputs
  4. Log the trimmed SQL to confirm what actually reaches executeQuery when debugging

Example fix

// before
res, err := server.executeQuery(queryOptions{SQL: req.SQL}) // req.SQL == ""
// after
if strings.TrimSpace(req.SQL) == "" {
    return errors.New("SQL is required")
}
res, err := server.executeQuery(queryOptions{SQL: req.SQL})
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(options.SQL) == "" {
    return errors.New("SQL is required")
}

Try / catch

res, err := server.executeQuery(queryOptions{SQL: sql, MaxRows: 100})
if err != nil && err.Error() == "SQL is required" {
    return fmt.Errorf("query rejected: empty SQL")
}

Prevention

When it happens

Trigger: Calling executeQuery (directly or via dispatch, connectionInfo, listDatabases, listTables, listRoutines, getColumns) with queryOptions.SQL set to "" or whitespace-only after trimStatementSQL.

Common situations: Client submits an empty query box; a template variable interpolates to nothing; a metadata helper builds SQL from an empty name; request params omit the sql field so queryOptions.SQL is the zero value.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/75db4f7ec7a69803. Report an issue: GitHub.