{"record":{"id":"8eff009db6202b51","repo":"apache/seatunnel","slug":"unknown-sqlserver-binary-type-defaulting-to-l","errorCode":null,"errorMessage":"Unknown SQLServer binary type: {}, defaulting to LONGVARBINARY. This may cause issues if the target column is not a large binary type.","messagePattern":"Unknown SQLServer binary type: (.+?), defaulting to LONGVARBINARY\\. This may cause issues if the target column is not a large binary type\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/sqlserver/SqlserverJdbcRowConverter.java","lineNumber":135,"sourceCode":"        if (sourceType == null) {\n            log.warn(\n                    \"Cannot determine source type for BYTES field, defaulting to VARBINARY. \"\n                            + \"If this causes errors, please provide databaseTableSchema.\");\n            return java.sql.Types.VARBINARY;\n        }\n\n        if (SqlServerTypeConverter.SQLSERVER_IMAGE.equals(sourceType)) {\n            return java.sql.Types.LONGVARBINARY;\n        }\n        if (sourceType.startsWith(SqlServerTypeConverter.SQLSERVER_VARBINARY)) {\n            return java.sql.Types.VARBINARY;\n        }\n        if (sourceType.startsWith(SqlServerTypeConverter.SQLSERVER_BINARY)) {\n            return java.sql.Types.BINARY;\n        }\n\n        // Unknown type, log warning and use conservative LONGVARBINARY\n        log.warn(\n                \"Unknown SQLServer binary type: {}, defaulting to LONGVARBINARY. \"\n                        + \"This may cause issues if the target column is not a large binary type.\",\n                sourceType);\n        return java.sql.Types.VARBINARY;\n    }\n}\n","sourceCodeStart":117,"sourceCodeEnd":142,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/sqlserver/SqlserverJdbcRowConverter.java#L117-L142","documentation":"SqlserverJdbcRowConverter.resolveSqlServerBytesNullType maps a SQLServer source binary type name to a java.sql.Types constant for setNull calls. When the type name starts with none of the known binary prefixes (VARBINARY/BINARY/IMAGE), it logs this warning and conservatively falls back to VARBINARY (declared as LONGVARBINARY semantics). The write proceeds but null semantics may not match the actual target column type.","triggerScenarios":"Calling setNullToStatementByDataType for a SQLServer binary column whose sourceType string is not a recognized SQLSERVER_* binary constant (e.g. a custom or renamed binary type name, or a type name with unexpected casing/whitespace).","commonSituations":"Reading from a SQLServer variant or newer version that introduces a binary type name not in SqlServerTypeConverter's mapping; schema metadata returning lowercased or suffixed type strings; replicating from third-party SQLServer-compatible databases (e.g. Azure SQL edge cases).","solutions":["Check the actual column type in SQLServer (INFORMATION_SCHEMA.COLUMNS) and confirm the sourceType string reaching the converter matches a supported SqlServerTypeConverter constant","Explicitly cast/alter the column to VARBINARY(MAX), BINARY, or IMAGE so it maps to a known constant","Add the unknown type name to SqlServerTypeConverter's binary mapping and to resolveSqlServerBytesNullType, then rebuild","Ignore the warning if VARBINARY null handling is acceptable for the target column"],"exampleFix":"// before (unknown type reaching converter)\nsourceType = \"varbinary_custom\"\n// after (normalize upstream or add mapping)\nsourceType = sourceType.toUpperCase(); // matches SQLSERVER_BINARY prefix\n// or add to converter: if (sourceType.startsWith(\"VARBINARY_CUSTOM\")) return Types.VARBINARY;","handlingStrategy":"validation","validationCode":"// Before the sink runs, verify SQLServer binary column types are supported:\nSet<String> known = Set.of(\"VARBINARY\", \"BINARY\", \"IMAGE\");\nfor (Column c : catalogTable.getTableSchema().columns()) {\n    String t = c.getSourceDataType() == null ? \"\" : c.getSourceDataType().toString().toUpperCase();\n    if (t.contains(\"BINARY\") && known.stream().noneMatch(t::startsWith)) {\n        throw new IllegalStateException(\"Unsupported SQLServer binary type: \" + t + \" for column \" + c.getName());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Audit source table schemas for non-standard binary type names before the job","Normalize type strings (uppercase/trim) in upstream metadata retrieval","Pin to SQLServer versions whose types are covered by SqlServerTypeConverter","Monitor logs for this warning in staging before production runs"],"tags":["jdbc","sqlserver","type-mapping","binary-data"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}