{"record":{"id":"f39a822e9ca7ee96","repo":"apache/druid","slug":"attempt-to-get-long-from-string-only-scalar-bi","errorCode":null,"errorMessage":"attempt to get long[] from string[] only scalar binding","messagePattern":"attempt to get long\\[\\] from string\\[\\] only scalar binding","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputDeferredEvaluationExpressionDimensionVectorSelector.java","lineNumber":158,"sourceCode":"      return 1;\n    }\n\n    @Override\n    public int getCurrentVectorId()\n    {\n      return -1;\n    }\n\n    @Override\n    public Object[] getObjectVector(String name)\n    {\n      return currentValue;\n    }\n\n    @Override\n    public long[] getLongVector(String name)\n    {\n      throw new UnsupportedOperationException(\"attempt to get long[] from string[] only scalar binding\");\n    }\n\n    @Override\n    public double[] getDoubleVector(String name)\n    {\n      throw new UnsupportedOperationException(\"attempt to get double[] from string[] only scalar binding\");\n    }\n\n    @Nullable\n    @Override\n    public boolean[] getNullVector(String name)\n    {\n      throw new UnsupportedOperationException(\"attempt to get boolean[] null vector from string[] only scalar binding\");\n    }\n  }\n}\n","sourceCodeStart":140,"sourceCodeEnd":175,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/virtual/SingleStringInputDeferredEvaluationExpressionDimensionVectorSelector.java#L140-L175","documentation":"The StringLookupVectorInputBindings inside SingleStringInputDeferredEvaluationExpressionDimensionVectorSelector only supplies the string value of the single input; array-typed accessors like getLongVector are unsupported because the binding is a string-only scalar/array-of-string source. An expression attempting long[] vector input triggers UnsupportedOperationException.","triggerScenarios":"An expression evaluated through this binding calls getLongVector(name) — e.g. an expression over the string column that the vector engine typed as a long[] input, or a misplanned multi-value input.","commonSituations":"Vectorized expressions mixing types (long-typed function applied to a string input binding), engine bugs in expression input typing, or custom expressions assuming array-of-long inputs.","solutions":["Ensure the expression's input type matches the string binding (use string-compatible functions)","Cast the input explicitly in the expression (e.g. parse/CAST to long) so planners use the right selector","Disable vectorization for the query as a workaround","Check the expression's analyzeInputs() types against the string-only binding"],"exampleFix":"// before\nlong_expr(string_col) + 1  -- expects long[] input\n// after\nCAST(string_col AS BIGINT) + 1 -- or use string functions on the binding","handlingStrategy":"try-catch","validationCode":"if (expr.analyzeInputs().getRequiredBindings().stream().anyMatch(b -> b.getType() != ExpressionType.STRING)) {\n  // re-plan with explicit CAST or non-vector engine\n}","typeGuard":null,"tryCatchPattern":"try {\n  result = evalVectorExpression(expr, bindings);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"string[] only scalar binding\")) {\n    result = evalNonVector(expr);\n  } else throw e;\n}","preventionTips":["Match expression input types to the string binding with explicit CASTs","Avoid vectorized expressions that expect long[]/double[] inputs on string columns","Test vectorization on queries with mixed-type expressions"],"tags":["druid","vectorized-query","expression","type-mismatch"],"backgroundTag":"unsupported-operation","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"}