apache/seatunnel · warning

Unknown SQLServer binary type

Error message

Unknown SQLServer binary type: {}, defaulting to LONGVARBINARY. This may cause issues if the target column is not a large binary type.

What it means

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.

Solutions

  1. Check the actual column type in SQLServer (INFORMATION_SCHEMA.COLUMNS) and confirm the sourceType string reaching the converter matches a supported SqlServerTypeConverter constant
  2. Explicitly cast/alter the column to VARBINARY(MAX), BINARY, or IMAGE so it maps to a known constant
  3. Add the unknown type name to SqlServerTypeConverter's binary mapping and to resolveSqlServerBytesNullType, then rebuild
  4. Ignore the warning if VARBINARY null handling is acceptable for the target column

Example fix

// before (unknown type reaching converter)
sourceType = "varbinary_custom"
// after (normalize upstream or add mapping)
sourceType = sourceType.toUpperCase(); // matches SQLSERVER_BINARY prefix
// or add to converter: if (sourceType.startsWith("VARBINARY_CUSTOM")) return Types.VARBINARY;
Defensive patterns

Strategy: validation

Validate before calling

// Before the sink runs, verify SQLServer binary column types are supported:
Set<String> known = Set.of("VARBINARY", "BINARY", "IMAGE");
for (Column c : catalogTable.getTableSchema().columns()) {
    String t = c.getSourceDataType() == null ? "" : c.getSourceDataType().toString().toUpperCase();
    if (t.contains("BINARY") && known.stream().noneMatch(t::startsWith)) {
        throw new IllegalStateException("Unsupported SQLServer binary type: " + t + " for column " + c.getName());
    }
}

Prevention

When it happens

Trigger: 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).

Common situations: 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).

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/8eff009db6202b51. 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:135

        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. "
                        + "This may cause issues if the target column is not a large binary type.",
                sourceType);
        return java.sql.Types.VARBINARY;
    }
}

View on GitHub (pinned to cf67b549a7)