apache/seatunnel · warning
Cannot determine source type for BYTES field, defaulting to…
Error message
Cannot determine source type for BYTES field, defaulting to VARBINARY. If this causes errors, please provide databaseTableSchema.
What it means
When binding a NULL for a BYTES field, the JDBC row converter needs the SQL Server column type (IMAGE vs VARBINARY/BINARY) to pick the right java.sql.Types null marker. If the source type metadata is null (no databaseTableSchema provided), it logs a warning and defaults to Types.VARBINARY, which may fail on IMAGE columns.
Solutions
- Configure databaseTableSchema so the connector knows the actual column type (IMAGE/VARBINARY/BINARY).
- If the target column is already VARBINARY, ignore the warning — the default is correct.
- Alter the SQL Server column to VARBINARY(MAX) (IMAGE is deprecated) so the VARBINARY null binding always works.
- Patch resolveSqlServerBytesNullType to pass a specific type when known from table metadata.
Example fix
// before (no schema info)
source {
Jdbc { url = "jdbc:sqlserver://..." }
}
// after
source {
Jdbc {
url = "jdbc:sqlserver://..."
databaseTableSchema = "dbo"
databaseTableName = "my_table"
}
} Defensive patterns
Strategy: fallback
Validate before calling
// Ensure schema metadata is configured so BYTES nulls bind with the right type:
assert config.hasPath("databaseTableSchema") : "databaseTableSchema required when syncing image/varbinary columns"; Type guard
int bytesNullType(String sourceType) { return "IMAGE".equals(sourceType) ? java.sql.Types.BINARY : java.sql.Types.VARBINARY; } Try / catch
try { ps.setNull(i, resolveSqlServerBytesNullType(sourceType)); } catch (SQLException e) { log.warn("Null bind failed for BYTES column; consider VARBINARY(MAX) instead of IMAGE", e); throw e; } Prevention
- Always set databaseTableSchema/databaseTableName when tables contain binary columns
- Migrate IMAGE columns to VARBINARY(MAX) — IMAGE is deprecated
- Test pipelines with NULL blob values before production runs
When it happens
Trigger: resolveSqlServerBytesNullType is invoked from setNullToStatementByDataType with sourceType == null — i.e., the sink writes NULL bytes without the source column's type string, typically when databaseTableSchema is not configured.
Common situations: SQL Server CDC/sync jobs writing NULL image/blob columns without schema info; upgrading pipelines where null typing previously worked because the target column was VARBINARY.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Column ' ' in table is NOT NULL but has no DEFAULT; adding…
- Column ' ' not found in .COLUMNS for table ; assuming NOT…
- COMMON-17
- COMMON-19
- Couldn't obtain database name
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/a5a033cd69c7c3dc.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/sqlserver/SqlserverJdbcRowConverter.java:118
/**
* Resolves the appropriate JDBC type for SQL Server binary columns when the value is null.
*
* <p>SQL Server has multiple binary types, each mapping to a different JDBC type:
*
* <ul>
* <li>IMAGE → LONGVARBINARY (legacy large binary type)
* <li>VARBINARY(*) → VARBINARY
* <li>VARBINARY(MAX) → VARBINARY
* <li>BINARY(*) → BINARY (fixed-length)
* <li>other → VARBINARY
* </ul>
*
* @param sourceType the SQL Server column type (e.g., "IMAGE", "VARBINARY", "BINARY")
* @return the JDBC type constant from {@link java.sql.Types}
*/
private int resolveSqlServerBytesNullType(@Nullable String sourceType) {
if (sourceType == null) {
log.warn(
"Cannot determine source type for BYTES field, defaulting to VARBINARY. "
+ "If this causes errors, please provide databaseTableSchema.");
return java.sql.Types.VARBINARY;
}
if (SqlServerTypeConverter.SQLSERVER_IMAGE.equals(sourceType)) {
return java.sql.Types.LONGVARBINARY;
}
if (sourceType.startsWith(SqlServerTypeConverter.SQLSERVER_VARBINARY)) {
return java.sql.Types.VARBINARY;
}
if (sourceType.startsWith(SqlServerTypeConverter.SQLSERVER_BINARY)) {
return java.sql.Types.BINARY;
}
// Unknown type, log warning and use conservative LONGVARBINARY
log.warn(
"Unknown SQLServer binary type: {}, defaulting to LONGVARBINARY. "View on GitHub (pinned to cf67b549a7)