{"record":{"id":"2dd0b236a780bf03","repo":"apache/seatunnel","slug":"array-inject-error-unsupported-data-type-typ","errorCode":null,"errorMessage":"array inject error, unsupported data type: \" + type","messagePattern":"array inject error, unsupported data type: \" \\+ type","errorType":"exception","errorClass":"ClickhouseConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/inject/ArrayInjectFunction.java","lineNumber":81,"sourceCode":"            case \"Int64\":\n            case \"UInt64\":\n                sqlType = \"BIGINT\";\n                elements = Arrays.copyOf(elements, elements.length, Long[].class);\n                break;\n            case \"Float32\":\n                sqlType = \"REAL\";\n                elements = Arrays.copyOf(elements, elements.length, Float[].class);\n                break;\n            case \"Float64\":\n                sqlType = \"DOUBLE\";\n                elements = Arrays.copyOf(elements, elements.length, Double[].class);\n                break;\n            case \"Bool\":\n                sqlType = \"BOOLEAN\";\n                elements = Arrays.copyOf(elements, elements.length, Boolean[].class);\n                break;\n            default:\n                throw new ClickhouseConnectorException(\n                        CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE,\n                        \"array inject error, unsupported data type: \" + type);\n        }\n        statement.setArray(index, statement.getConnection().createArrayOf(sqlType, elements));\n    }\n\n    @Override\n    public boolean isCurrentFieldType(String fieldType) {\n        if (PATTERN.matcher(fieldType).matches()) {\n            this.fieldType = fieldType;\n            return true;\n        }\n        return false;\n    }\n}\n","sourceCodeStart":63,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/inject/ArrayInjectFunction.java#L63-L97","documentation":"ArrayInjectFunction.injectFields() maps a SeaTunnel array element type to a SQL type for createArrayOf; any element type outside its known switch cases (Int, BigInt/Long, Float, Double, String, Decimal, Date/Timestamp, Bool) hits the default branch and throws UNSUPPORTED_DATA_TYPE. The ClickHouse sink cannot serialize that array element type into a prepared statement.","triggerScenarios":"A source/table schema contains an Array column whose inner type is not one of the supported primitives (e.g. Array of bytes, nested arrays, or a newly added SeaTunnel type not yet mapped in the switch).","commonSituations":"Reading from a source with Array<Int8>/byte arrays, Array<Array<...>> nested arrays, or upgrading SeaTunnel where a new BasicType was introduced but the ClickHouse ArrayInjectFunction lacks a case for it.","solutions":["Cast/flatten the unsupported array column to a supported element type upstream (e.g. via a Transform) before the ClickHouse sink","Check which element type hits the default branch from the log/config and confirm it is genuinely unsupported","If the type is a newly added SeaTunnel type, upgrade SeaTunnel or file/patch a case for it in ArrayInjectFunction","As a workaround, serialize the array to a string column and parse in ClickHouse"],"exampleFix":"// before (in ArrayInjectFunction.java)\ndefault:\n    throw new ClickhouseConnectorException(\n        CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE,\n        \"array inject error, unsupported data type: \" + type);\n// after: add a case for the missing type\ncase \"TinyInt\":\n    sqlType = \"INT8\";\n    elements = Arrays.copyOf(elements, elements.length, Byte[].class);\n    break;","handlingStrategy":"validation","validationCode":"// validate array element types against supported set before sinking\njava.util.Set<String> supported = java.util.Set.of(\n    \"Int\", \"BigInt\", \"Float\", \"Double\", \"String\", \"Decimal\", \"Date\", \"Timestamp\", \"Bool\", \"BooleanType\");\ncatalogTable.getTableSchema().getColumns().stream()\n    .filter(c -> c.getDataType() instanceof ArrayType)\n    .forEach(c -> {\n        String inner = ((ArrayType) c.getDataType()).getElementType().toString();\n        if (!supported.contains(inner)) {\n            throw new IllegalArgumentException(\"Unsupported array element type for ClickHouse sink: \" + inner);\n        }\n    });","typeGuard":"boolean isArrayTypeSupported(SeaTunnelDataType<?> t) {\n    return t instanceof ArrayType && java.util.Set.of(\"Int\",\"BigInt\",\"Float\",\"Double\",\"String\",\"Decimal\",\"Date\",\"Timestamp\",\"Bool\")\n        .contains(((ArrayType) t).getElementType().toString());\n}","tryCatchPattern":"try {\n    sinkWriter.write(row);\n} catch (ClickhouseConnectorException e) {\n    if (String.valueOf(e.getMessage()).startsWith(\"array inject error, unsupported data type\")) {\n        throw new IllegalArgumentException(\"Cast the array column to a supported element type upstream\", e);\n    }\n    throw e;\n}","preventionTips":["Inspect source schemas for Array columns and their inner types before using the ClickHouse sink","Add a Transform to cast/flatten unsupported array types","After SeaTunnel upgrades, diff new BasicType values against ArrayInjectFunction's switch cases","Avoid nested arrays and byte arrays in ClickHouse sink schemas"],"tags":["unsupported-type","array","data-type","clickhouse","serialization"],"backgroundTag":"unsupported-dtype","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}