{"record":{"id":"e3f958b7be58279b","repo":"apache/druid","slug":"cannot-stringify-array-type-s","errorCode":null,"errorMessage":"cannot stringify array type %s","messagePattern":"cannot stringify array type (.+?)","errorType":"exception","errorClass":"IAE","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/math/expr/ConstantExpr.java","lineNumber":505,"sourceCode":"      );\n    } else if (outputType.getElementType().isNumeric()) {\n      return outputType.asTypeString() + Arrays.toString(value);\n    } else if (outputType.getElementType().is(ExprType.COMPLEX)) {\n      Object[] stringified = new Object[value.length];\n      for (int i = 0; i < value.length; i++) {\n        stringified[i] = new ComplexExpr((ExpressionType) outputType.getElementType(), value[i]).stringify();\n      }\n      // use array function to rebuild since we can't stringify complex types directly\n      return StringUtils.format(\"array(%s)\", Arrays.toString(stringified));\n    } else if (outputType.getElementType().isArray()) {\n      // use array function to rebuild since the parser can't yet recognize nested arrays e.g. [['foo', 'bar'],['baz']]\n      Object[] stringified = new Object[value.length];\n      for (int i = 0; i < value.length; i++) {\n        stringified[i] = new ArrayExpr((ExpressionType) outputType.getElementType(), (Object[]) value[i]).stringify();\n      }\n      return StringUtils.format(\"array(%s)\", Arrays.toString(stringified));\n    }\n    throw new IAE(\"cannot stringify array type %s\", outputType);\n  }\n\n  @Override\n  public boolean equals(Object o)\n  {\n    if (this == o) {\n      return true;\n    }\n    if (o == null || getClass() != o.getClass()) {\n      return false;\n    }\n    ArrayExpr that = (ArrayExpr) o;\n    return outputType.equals(that.outputType) && Arrays.equals(value, that.value);\n  }\n\n  @Override\n  public int hashCode()\n  {","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/math/expr/ConstantExpr.java#L487-L523","documentation":"ConstantExpr.stringify can render array constants whose elements are arrays (nested arrays), but if outputType is an array type with an element type it does not recognize in its switch, it throws IllegalArgumentException saying the array type cannot be stringified. It is an internal representation limitation of the expression printer.","triggerScenarios":"Calling stringify() (directly or via error messages/EXPLAIN that print expressions) on an array-typed ConstantExpr whose element type isn't one of the handled primitive array element types.","commonSituations":"Nested array literals in expressions hitting an unhandled ExpressionType element type; printing expressions for logging or plan display; new array types added before stringify support caught up.","solutions":["Avoid nested array constants in expressions; flatten to a single-level array literal","Upgrade Druid to a version where the element type is supported in stringify","Write the expression using array(...) constructor syntax over scalar elements instead of a pre-built constant"],"exampleFix":"// before: constant nested array expr ARRAY[ARRAY[1,2]]\n// after\n\"ARRAY_CONCAT(ARRAY[1], ARRAY[2])\" // keep expressions single-level","handlingStrategy":"try-catch","validationCode":"if (expr instanceof ConstantExpr) {\n  ExpressionType t = ((ConstantExpr) expr).outputType();\n  if (t.isArray() && !isSupportedArrayElementType(t.getElementType())) { /* avoid stringify */ }\n}","typeGuard":null,"tryCatchPattern":"try {\n  s = constantExpr.stringify();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"cannot stringify array type\")) {\n    s = expr.toString(); // fallback representation\n  } else { throw e; }\n}","preventionTips":["Avoid nested array constants in expressions","Keep single-level array literals","Test stringify/EXPLAIN output when using new array types"],"tags":["expressions","arrays","serialization"],"backgroundTag":"unsupported-operation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}