alibaba/DataX · error · IllegalArgumentException

type={type}

Error message

type={type}

What it means

Thrown by DataType.toString(type) in the adswriter odps package when the byte constant passed in is not one of INTEGER, DOUBLE, BOOLEAN, STRING, DATETIME. It is the default branch of a switch converting internal type constants to ODPS type name strings, so any unmapped constant produces this error with the raw value interpolated.

Source

Thrown at adswriter/src/main/java/com/alibaba/datax/plugin/writer/adswriter/odps/DataType.java:39

    public final static byte DOUBLE = 1;
    public final static byte BOOLEAN = 2;
    public final static byte STRING = 3;
    public final static byte DATETIME = 4;

    public static String toString(int type) {
        switch (type) {
            case INTEGER:
                return "bigint";
            case DOUBLE:
                return "double";
            case BOOLEAN:
                return "boolean";
            case STRING:
                return "string";
            case DATETIME:
                return "datetime";
            default:
                throw new IllegalArgumentException("type=" + type);
        }
    }

    /**
     * 字符串的数据类型转换为byte常量定义的数据类型.
     * <p>
     * 转换规则:
     * <ul>
     * <li>tinyint, int, bigint, long - {@link #INTEGER}
     * <li>double, float - {@link #DOUBLE}
     * <li>string - {@link #STRING}
     * <li>boolean, bool - {@link #BOOLEAN}
     * <li>datetime - {@link #DATETIME}
     * </ul>
     * </p>
     *
     * @param type 字符串的数据类型
     * @return byte常量定义的数据类型

View on GitHub (pinned to 80ec23d5c5)

Solutions

  1. Inspect the interpolated type value to see which constant leaked in
  2. Ensure the type byte comes from DataType.asType(...)/this class's own constants, not a foreign module
  3. Initialize type fields before use and add the missing constant-to-string mapping if the type is legitimate
  4. Rebuild adswriter with matching DataX common/odps dependency versions
Defensive patterns

Strategy: validation

Validate before calling

// ensure the byte comes from a valid constant before calling toString
if (type != DataType.INTEGER && type != DataType.DOUBLE && type != DataType.BOOLEAN
        && type != DataType.STRING && type != DataType.DATETIME) {
    throw new IllegalStateException("Unsupported DataType byte: " + type);
}

Type guard

static boolean isValidDataType(byte t) {
    return t == DataType.INTEGER || t == DataType.DOUBLE || t == DataType.BOOLEAN
            || t == DataType.STRING || t == DataType.DATETIME;
}

Try / catch

catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("type=")) { /* log the byte value, check version skew */ }
  throw e;
}

Prevention

When it happens

Trigger: Calling DataType.toString with a byte constant that was never defined in this class — e.g. a constant obtained from another module/version, or an uninitialized (0/default) type field that does not map to any case.

Common situations: Version skew between modules defining type constants; a code path that passes a default-initialized DataType field before assignment; new type added to constants but not to toString.

Related errors


AI-assisted analysis of alibaba/DataX@80ec23d5c5 (2026-08-14). Data as JSON: /api/errors/f07700d6116704e0. Report an issue: GitHub.