{"record":{"id":"f222e90973467da5","repo":"apache/beam","slug":"failed-to-get-table-schema-for-table","errorCode":null,"errorMessage":"Failed to get table schema for table: ","messagePattern":"Failed to get table schema for table: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/clickhouse/src/main/java/org/apache/beam/sdk/io/clickhouse/ClickHouseIO.java","lineNumber":784,"sourceCode":"            }\n            DefaultType defaultType = DefaultType.parse(defaultTypeStr).orElse(null);\n\n            Object defaultValue;\n            if (DefaultType.DEFAULT.equals(defaultType)\n                && !Strings.isNullOrEmpty(defaultExpression)) {\n              defaultValue = ColumnType.parseDefaultExpression(columnType, defaultExpression);\n            } else {\n              defaultValue = null;\n            }\n\n            columns.add(TableSchema.Column.of(name, columnType, defaultType, defaultValue));\n          }\n        }\n      }\n\n      return TableSchema.of(columns.toArray(new TableSchema.Column[0]));\n    } catch (Exception e) {\n      throw new RuntimeException(\"Failed to get table schema for table: \" + table, e);\n    }\n  }\n\n  @VisibleForTesting\n  static String buildClientName(Properties properties) {\n    String beamAgent =\n        String.format(\"Apache Beam/%s\", ReleaseInfo.getReleaseInfo().getSdkVersion());\n    String existingClientName = properties.getProperty(\"client_name\");\n    if (!Strings.isNullOrEmpty(existingClientName)) {\n      return beamAgent + \" \" + existingClientName;\n    }\n    return beamAgent;\n  }\n\n  static String quoteIdentifier(String identifier) {\n    String backslash = \"\\\\\\\\\";\n    String quote = \"\\\"\";\n","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/clickhouse/src/main/java/org/apache/beam/sdk/io/clickhouse/ClickHouseIO.java#L766-L802","documentation":"ClickHouseIO fetches the target table's schema (columns and types) at expansion time to map it to a Beam schema. Any exception during this metadata lookup — connection failure, unknown table, insufficient privileges, unsupported type — is caught and rethrown as RuntimeException(\"Failed to get table schema for table: \" + table) with the original cause attached.","triggerScenarios":"Calling ClickHouseIO.read/write expansion against a table that does not exist, a database the user cannot read, an unreachable ClickHouse endpoint, or a table with column types the mapper cannot handle.","commonSituations":"Typo in table or database name; wrong environment URL (staging vs prod); user lacking SELECT/DESCRIBE grants; table created after the pipeline was built, or against a replica that is down.","solutions":["Check the wrapped cause for the real error (connection refused, auth, unknown table)","Verify the table/database name and that it exists: run DESCRIBE TABLE in a ClickHouse client","Confirm the JDBC user has privileges to read the table metadata","Validate connectivity from the Beam environment (host/port/TLS settings)"],"exampleFix":"// before\nClickHouseIO.<Row>read(\"jdbc:clickhouse://host:8123/default\", \"custmers\")\n// after\nClickHouseIO.<Row>read(\"jdbc:clickhouse://host:8123/default\", \"customers\") // table exists and user has grants","handlingStrategy":"try-catch","validationCode":"// verify the table exists and is describable before expansion\ntry (Statement s = DriverManager.getConnection(jdbcUrl).createStatement()) {\n  s.executeQuery(\"DESCRIBE TABLE \" + table); // throws early if missing/no grants\n}","typeGuard":null,"tryCatchPattern":"try {\n  ClickHouseIO.<Row>read(jdbcUrl, table);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Failed to get table schema\")) {\n    LOG.error(\"Schema fetch failed for {} — cause: {}\", table, e.getCause());\n  }\n  throw e;\n}","preventionTips":["Validate table/database names against the target environment before deploying","Grant the JDBC user metadata/SELECT privileges on the table","Test connectivity from the Beam worker network (host, port, TLS)","Re-check the schema after ClickHouse version upgrades for unsupported types"],"tags":["java","clickhouse","beam","schema","metadata"],"backgroundTag":"resource-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}