{"record":{"id":"58facff5a57c0ace","repo":"alibaba/canal","slug":"dbmapping-targettable","errorCode":null,"errorMessage":"dbMapping.targetTable","messagePattern":"dbMapping\\.targetTable","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"client-adapter/clickhouse/src/main/java/com/alibaba/otter/canal/client/adapter/clickhouse/config/MappingConfig.java","lineNumber":92,"sourceCode":"    }\n\n    public void setDestination(String destination) {\n        this.destination = destination;\n    }\n\n    public AdapterMapping getMapping() {\n        return dbMapping;\n    }\n\n    public void validate() {\n        if (dbMapping.database == null || dbMapping.database.isEmpty()) {\n            throw new NullPointerException(\"dbMapping.database\");\n        }\n        if (!dbMapping.getMirrorDb() && (dbMapping.table == null || dbMapping.table.isEmpty())) {\n            throw new NullPointerException(\"dbMapping.table\");\n        }\n        if (!dbMapping.getMirrorDb() && (dbMapping.targetTable == null || dbMapping.targetTable.isEmpty())) {\n            throw new NullPointerException(\"dbMapping.targetTable\");\n        }\n    }\n\n    public static class DbMapping implements AdapterMapping {\n\n        private boolean             mirrorDb        = false;                 // 是否镜像库\n        private String              database;                                // 数据库名或schema名\n        private String              table;                                   // 表名\n        private Map<String, String> targetPk        = new LinkedHashMap<>(); // 目标表主键字段\n        private boolean             mapAll          = false;                 // 映射所有字段\n        private String              targetDb;                                // 目标库名\n        private String              targetTable;                             // 目标表名\n        private Map<String, String> targetColumns;                           // 目标表字段映射\n\n        private boolean             caseInsensitive = false;                 // 目标表不区分大小写，默认是否\n\n        private String              etlCondition;                            // etl条件sql\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/client-adapter/clickhouse/src/main/java/com/alibaba/otter/canal/client/adapter/clickhouse/config/MappingConfig.java#L74-L110","documentation":"Thrown as NullPointerException by MappingConfig.validate when, for a non-mirrorDb config, dbMapping.targetTable is null or empty. targetTable is the destination ClickHouse table name; required for non-mirrorDb configs. mirrorDb configs are exempt because they derive target tables automatically.","triggerScenarios":"A non-mirror mapping yml omitting targetTable; targetTable set to empty; intending source and target names to be equal but leaving the field blank (it is not auto-defaulted from table).","commonSituations":"Configuring a sync where the target ClickHouse table name was assumed to default to the source table name (it does not); template with blank targetTable; YAML indentation error.","solutions":["Set dbMapping.targetTable to the destination ClickHouse table name (even if identical to table).","For whole-DB mirroring, set dbMapping.mirrorDb: true to bypass the requirement.","Verify YAML indentation and restart the adapter."],"exampleFix":"# before:\ndbMapping:\n  database: shop\n  table: orders\n# after:\ndbMapping:\n  database: shop\n  table: orders\n  targetTable: orders","handlingStrategy":"validation","validationCode":"MappingConfig.DbMapping m = config.getDbMapping();\nif (!m.getMirrorDb() && (m.getTargetTable() == null || m.getTargetTable().isEmpty())) {\n    throw new IllegalArgumentException(\"dbMapping.targetTable is required for non-mirrorDb config (file: \" + fileName + \")\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set dbMapping.targetTable, even when it equals the source table name.","Use mirrorDb:true for whole-database mirroring to bypass the requirement.","Lint configs in CI to catch a missing targetTable."],"tags":["clickhouse-adapter","canal-adapter","config","validation","null-pointer"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}