{"record":{"id":"e91c1692c94e4db6","repo":"t8y2/dbx","slug":"hiveserver2-metadata-failed-v-s-fallback-fail-e91c16","errorCode":null,"errorMessage":"HiveServer2 metadata failed (%v); %s fallback failed: %w","messagePattern":"HiveServer2 metadata failed \\((.+?)\\); (.+?) fallback failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/hive-go/metadata.go","lineNumber":358,"sourceCode":"\t}\n\tif containsString(requestedTypes, \"VIEW\") || containsString(requestedTypes, \"MATERIALIZED VIEW\") {\n\t\tfallbackQueries = append(fallbackQueries, fallbackQuery{\n\t\t\toperation:  \"SHOW VIEWS\",\n\t\t\tstatement:  \"SHOW VIEWS IN \" + quoteHiveIdentifier(schema),\n\t\t\tobjectType: \"VIEW\",\n\t\t})\n\t}\n\tobjectsByName := make(map[string]tableInfo)\n\ttableFallbackSucceeded := false\n\tfor _, fallback := range fallbackQueries {\n\t\tresult, err := server.executeQuery(queryOptions{SQL: fallback.statement, MaxRows: metadataQueryLimit})\n\t\tif err != nil {\n\t\t\t// Older Hive and Impala versions can list tables but do not support SHOW VIEWS.\n\t\t\t// Keep the usable table result for mixed requests; explicit view requests still fail.\n\t\t\tif fallback.objectType == \"VIEW\" && tableFallbackSucceeded && showViewsUnsupported(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"HiveServer2 metadata failed (%v); %s fallback failed: %w\", metadataErr, fallback.operation, err)\n\t\t}\n\t\tif fallback.objectType == \"TABLE\" {\n\t\t\ttableFallbackSucceeded = true\n\t\t}\n\t\tfor _, row := range result.Rows {\n\t\t\tname := showTablesRowName(result.Columns, row)\n\t\t\tif name == \"\" || !metadataNameMatches(name, constraints.Filter) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcandidate := tableInfo{Name: name, TableType: fallback.objectType, Comment: nil}\n\t\t\tif existing, ok := objectsByName[name]; ok && existing.TableType == \"VIEW\" && candidate.TableType != \"VIEW\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tobjectsByName[name] = candidate\n\t\t}\n\t}\n\tvalues := make([]tableInfo, 0, len(objectsByName))\n\tfor _, value := range objectsByName {","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/metadata.go#L340-L376","documentation":"listTables first uses HiveServer2 JDBC metadata (GetHiveTables). If that fails, it falls back to SHOW TABLES / SHOW VIEWS SQL statements. This error fires when a required fallback statement also fails; the message names which fallback operation failed and embeds the original metadata error. SHOW VIEWS failures are tolerated (skipped) only when SHOW TABLES already succeeded and the error indicates the statement is unsupported on that engine.","triggerScenarios":"Metadata API failure (permissions, unsupported driver path) combined with a failing SHOW TABLES or SHOW VIEWS — e.g. old Hive versions where SHOW VIEWS is unsupported for explicit view requests, or permission denial on the schema.","commonSituations":"Listing views on Hive 1.x/2.x or Impala that lacks SHOW VIEWS; schema-level permissions blocking both metadata and SHOW statements; quoting issues with special characters in the schema name.","solutions":["Fix the metadata error shown first (usually permission or driver capability)","If the failing fallback is SHOW VIEWS on an old engine, request tables and views separately or upgrade Hive","Grant the user SHOW TABLES/SHOW VIEWS rights on the target schema","Check schema name quoting — special characters must be properly escaped"],"exampleFix":"// before: requesting VIEW objects on an engine without SHOW VIEWS\n{objectTypes: [\"VIEW\"]}\n// after: request mixed types so the table fallback result is kept\n{objectTypes: [\"TABLE\", \"VIEW\"]}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"tables, err := server.listTables(schema, constraints)\nif err != nil && strings.Contains(err.Error(), \"SHOW VIEWS fallback failed\") {\n    return server.listTables(schema, metadataListConstraints{ObjectTypes: []string{\"TABLE\"}})\n}","preventionTips":["Avoid VIEW-only listings on Hive < 2.2 / Impala","Confirm SHOW TABLES works in beeline as the connect user","Align metadata and SQL permissions for the service account"],"tags":["hive","metadata","sql","fallback"],"backgroundTag":"metadata-query-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"}