{"record":{"id":"526d32cac08c048e","repo":"apache/druid","slug":"invalid-value-s","errorCode":null,"errorMessage":"invalid value %s","messagePattern":"invalid value (.+?)","errorType":"validation","errorClass":"ExpressionValidationException","httpStatus":400,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/math/expr/Function.java","lineNumber":3221,"sourceCode":"      }\n\n      DateTimes.UtcFormatter formatter = DateTimes.ISO_DATE_OPTIONAL_TIME;\n      if (args.size() > 1) {\n        ExprEval format = args.get(1).eval(bindings);\n        if (!format.type().is(ExprType.STRING)) {\n          throw validationFailed(\n              \"second argument should be STRING but got %s instead\",\n              format.type()\n          );\n        }\n        formatter = DateTimes.wrapFormatter(DateTimeFormat.forPattern(format.asString()));\n      }\n      DateTime date;\n      try {\n        date = formatter.parse(value.asString());\n      }\n      catch (IllegalArgumentException e) {\n        throw validationFailed(e, \"invalid value %s\", value.asString());\n      }\n      return toValue(date);\n    }\n\n    @Override\n    public void validateArguments(List<Expr> args)\n    {\n      validationHelperCheckAnyOfArgumentCount(args, 1, 2);\n    }\n\n    @Nullable\n    @Override\n    public ExpressionType getOutputType(Expr.InputBindingInspector inspector, List<Expr> args)\n    {\n      return ExpressionType.LONG;\n    }\n\n    protected ExprEval toValue(DateTime date)","sourceCodeStart":3203,"sourceCodeEnd":3239,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/math/expr/Function.java#L3203-L3239","documentation":"Thrown when Druid's time-parse expression function cannot parse the first argument's string value using the supplied (or default ISO) formatter. The underlying Joda-Time formatter raises IllegalArgumentException, which is wrapped into a validation failure naming the offending value.","triggerScenarios":"Calling the parse function with a date string that does not match the format pattern given as the second argument, or does not match ISO_DATE_OPTIONAL_TIME when no pattern is supplied, e.g. parse('2024/01/05') against pattern 'yyyy-MM-dd'.","commonSituations":"Locale/timezone-dependent formats; strings with trailing whitespace or unexpected timezone suffixes; data where some rows deviate from the declared pattern; using 'dd/MM' vs 'MM/dd' confusion.","solutions":["Align the format pattern (second argument) with the actual input string, e.g. parse(x, 'yyyy/MM/dd').","Test the pattern on a sample of the raw values to catch rows that deviate.","Clean/normalize the value first (TRIM, REPLACE) so it matches the pattern.","Pre-validate with a TRY/regexp expression so bad rows become NULL instead of failing the query."],"exampleFix":"// before\nparse(x, 'yyyy-MM-dd') -- x = '2024/01/05'\n// after\nparse(x, 'yyyy/MM/dd')","handlingStrategy":"try-catch","validationCode":"// pre-check in SQL: only parse values matching the pattern\nCASE WHEN REGEXP_LIKE(x, '^\\\\d{4}-\\\\d{2}-\\\\d{2}$') THEN parse(x, 'yyyy-MM-dd') ELSE NULL END","typeGuard":null,"tryCatchPattern":"try { runQuery(q); } catch (ExpressionValidationException e) { logBadValue(e); }","preventionTips":["Match the pattern exactly to input data, including separators","Trim whitespace before parsing","Sample raw data to confirm the format for all rows"],"tags":["druid","expressions","datetime","parsing"],"backgroundTag":"invalid-date-format","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}