t8y2/dbx · error

execute Hive initFile statement: %w

Error message

execute Hive initFile statement: %w

What it means

Wrapper error produced by `runHiveInitStatements` when `executeHiveStatement` returns an error while running one of the configured initFile statements on a freshly opened `*sql.Conn` during `openConnection`. The original driver error is preserved with %w; the wrapper only identifies which init statement phase failed. Since init statements run at connect time, any failure aborts the whole connection open (openConnection closes the conn and database and returns this error).

Source

Thrown at agents/drivers/argo-go/main.go:372

	}
	server.database = database
	server.connection = connection
	return nil
}

func (server *server) connectionOpenTimeout() time.Duration {
	timeout := server.config.ConnectTimeout
	if strings.EqualFold(server.config.Auth, "BROWSER") && strings.TrimSpace(server.config.BrowserToken) == "" {
		timeout += server.config.BrowserResponseTimeout
	}
	return timeout
}

func runHiveInitStatements(ctx context.Context, connection *sql.Conn, statements []string, fetchSize int) error {
	for _, statement := range statements {
		rows, _, hasResultSet, err := executeHiveStatement(ctx, connection, statement, fetchSize)
		if err != nil {
			return fmt.Errorf("execute Hive initFile statement: %w", err)
		}
		if !hasResultSet {
			continue
		}
		for rows.Next() {
		}
		if rowsErr := rows.Err(); rowsErr != nil {
			_ = rows.Close()
			return fmt.Errorf("read Hive initFile statement result: %w", rowsErr)
		}
		if closeErr := rows.Close(); closeErr != nil {
			return fmt.Errorf("close Hive initFile statement result: %w", closeErr)
		}
	}
	return nil
}

func (server *server) dispatch(method string, params map[string]json.RawMessage) (any, bool, error) {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Unwrap the error (%w) and fix the underlying Hive driver error reported for the failing statement; run the statement manually in beeline/Hive CLI to see the full message.
  2. Validate the initFile: remove or correct statements incompatible with your Hive version and confirm referenced databases/tables exist and the connecting user has privileges.
  3. Increase the connection open timeout (connectTimeout / browser response timeout) if init statements are slow rather than wrong.
  4. As a workaround, temporarily empty InitStatements to confirm connectivity itself is fine, then re-add statements one at a time to isolate the offender.

Example fix

// before (init.sql)
SET hive.support.concurrency=false;
USE analytics;
SELECT * FROM events;  -- fails: table renamed
// after
SET hive.support.concurrency=false;
USE analytics;
SELECT 1;  -- cheap, valid init statement
Defensive patterns

Strategy: validation

Validate before calling

// validate initFile statements before configuring the driver
for i, stmt := range initStatements {
    if strings.TrimSpace(stmt) == "" {
        return fmt.Errorf("init statement %d is empty", i)
    }
    if err := dryRunInBeeline(stmt); err != nil {
        return fmt.Errorf("init statement %d invalid: %w", i, err)
    }
}

Try / catch

err := runHiveInitStatements(ctx, conn, stmts, fetchSize)
if err != nil {
    var execErr error
    if errors.As(err, &execErr) && strings.Contains(err.Error(), "execute Hive initFile statement") {
        return fmt.Errorf("initFile rejected by Hive server: %w", err) // fix the SQL, not the transport
    }
    return err
}

Prevention

When it happens

Trigger: openConnection → runHiveInitStatements executes a statement from config.InitStatements and `executeHiveStatement` returns an error: invalid SQL syntax, missing target table/database, permission denied, Hive server query error, context timeout exceeded, or fetchSize misuse.

Common situations: initFile containing SQL valid in another engine (e.g. MySQL/Postgres syntax Hive rejects); USE/SET statements referencing a database the user cannot access; initFile grown stale after schema migrations; connect timeout too short for slow init queries; Kerberos/LDAP-authenticated user lacking privileges for init statements.

Related errors


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