{"record":{"id":"94882ba01354aac0","repo":"t8y2/dbx","slug":"execute-hive-initfile-statement-w-94882b","errorCode":null,"errorMessage":"execute Hive initFile statement: %w","messagePattern":"execute Hive initFile statement: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/hive-go/main.go","lineNumber":372,"sourceCode":"\t}\n\tserver.database = database\n\tserver.connection = connection\n\treturn nil\n}\n\nfunc (server *server) connectionOpenTimeout() time.Duration {\n\ttimeout := server.config.ConnectTimeout\n\tif strings.EqualFold(server.config.Auth, \"BROWSER\") && strings.TrimSpace(server.config.BrowserToken) == \"\" {\n\t\ttimeout += server.config.BrowserResponseTimeout\n\t}\n\treturn timeout\n}\n\nfunc runHiveInitStatements(ctx context.Context, connection *sql.Conn, statements []string, fetchSize int) error {\n\tfor _, statement := range statements {\n\t\trows, _, hasResultSet, err := executeHiveStatement(ctx, connection, statement, fetchSize)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"execute Hive initFile statement: %w\", err)\n\t\t}\n\t\tif !hasResultSet {\n\t\t\tcontinue\n\t\t}\n\t\tfor rows.Next() {\n\t\t}\n\t\tif rowsErr := rows.Err(); rowsErr != nil {\n\t\t\t_ = rows.Close()\n\t\t\treturn fmt.Errorf(\"read Hive initFile statement result: %w\", rowsErr)\n\t\t}\n\t\tif closeErr := rows.Close(); closeErr != nil {\n\t\t\treturn fmt.Errorf(\"close Hive initFile statement result: %w\", closeErr)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (server *server) dispatch(method string, params map[string]json.RawMessage) (any, bool, error) {","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/main.go#L354-L390","documentation":"This error wraps a failure to execute one of the SQL statements from the configured initFile during connection setup. openConnection runs every init statement through executeHiveStatement after the initial connect+ping; if any statement fails, connection establishment aborts with this wrapped error, stopping at the first failing statement.","triggerScenarios":"Any initFile statement that HiveServer2 rejects: syntax error, permission denial, referencing a non-existent database/table/function, a USE to a missing database, or a statement timing out during openConnection's context.","commonSituations":"initFile copied from another engine (e.g. Postgres SET options unsupported in Hive); USE database that doesn't exist for this user; ADD JAR paths not present on the server; per-user permissions on init statements.","solutions":["Read the wrapped cause after 'execute Hive initFile statement:' for the exact server error and statement order","Fix or remove the failing statement in the initFile configuration","Test initFile statements manually in beeline with the same user before configuring them","Ensure the connection user has permissions for every statement in the initFile"],"exampleFix":"// before: initFile with unsupported statement\nSET autocommit=false;\nUSE analytics;\n// after: Hive-compatible initFile\nUSE analytics;","handlingStrategy":"validation","validationCode":"for _, stmt := range initStatements {\n    if _, _, _, err := executeHiveStatement(ctx, conn, stmt, fetchSize); err != nil {\n        return fmt.Errorf(\"initFile statement %q failed: %w\", stmt, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := openConnection(); err != nil {\n    if strings.Contains(err.Error(), \"execute Hive initFile statement:\") {\n        log.Printf(\"initFile problem: %v\", errors.Unwrap(err))\n    }\n}","preventionTips":["Keep initFile minimal and engine-specific","Version-control the initFile and test it against the target Hive version","Run init statements as the same principal the driver connects with"],"tags":["go","hive","initialization","sql"],"backgroundTag":"init-script-failed","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}