{"record":{"id":"0c99f7786a84f0be","repo":"t8y2/dbx","slug":"hiveserver2-metadata-failed-v-s-fallback-fail","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/argo-go/metadata.go","lineNumber":352,"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":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/metadata.go#L334-L370","documentation":"listTables-style listing tries the HiveServer2 metadata provider first; when it errors, the driver falls back to SHOW TABLES/SHOW VIEWS statements. This error wraps both failures: the original metadata call (%v) and the named fallback operation (%w). Special case: for VIEW requests where SHOW TABLES already succeeded and SHOW VIEWS is unsupported by old Hive/Impala, the error is skipped and the table result is kept.","triggerScenarios":"Listing tables/views when GetHiveTables (or equivalent) metadata fails AND the corresponding SHOW TABLES / SHOW VIEWS fallback also errors. Explicit view-only requests on old Hive/Impala versions that lack SHOW VIEWS still produce this.","commonSituations":"Older Hive or Impala versions without SHOW VIEWS support; permission denial on both catalog metadata and SHOW statements; quoting issues in schema names passed to the fallback SQL.","solutions":["Read the (%v) portion to fix the primary HiveServer2 metadata failure (usually permissions or session state).","Run the named fallback statement (e.g. SHOW TABLES IN <schema>) manually as the same user to see why it failed.","On old Hive/Impala, avoid view-only listing requests, or upgrade the server to a version supporting SHOW VIEWS.","Verify schema/table identifier spelling and quoting in the request."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check the server supports SHOW VIEWS before issuing view-only listings on old Hive/Impala.\nresult, verr := server.executeQuery(queryOptions{SQL: \"SHOW VIEWS\", MaxRows: 1})\nsupportsShowViews := verr == nil","typeGuard":null,"tryCatchPattern":"tables, err := server.listTables(schema, opts)\nif err != nil {\n    if supportsShowViews == false && opts.ObjectType == \"VIEW\" {\n        // old Hive/Impala: fall back to treating table listing as the best available result\n        return tableOnlyResult, nil\n    }\n    return fmt.Errorf(\"table/view listing unavailable; check metadata privileges: %w\", err)\n}","preventionTips":["Detect server version once at connect and gate SHOW VIEWS usage on it.","Confirm the user can run SHOW TABLES IN <schema> before listing operations.","Avoid mixing view-only requests against old Hive/Impala clusters; request mixed listings instead.","Quote schema identifiers consistently before passing them into fallback SQL."],"tags":["hive","metadata","fallback","views"],"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-14T00:17:10.932Z"}