{"record":{"id":"62fa39c2e0a6160e","repo":"prestodb/presto","slug":"invalid-function-argument-62fa39","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"No value '%s' in enum type %s","messagePattern":"No value '(.+?)' in enum type (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/type/VarcharEnumOperators.java","lineNumber":161,"sourceCode":"    }\n\n    @ScalarOperator(BETWEEN)\n    @TypeParameter(value = \"T\", boundedBy = VARCHAR_ENUM)\n    @SqlType(StandardTypes.BOOLEAN)\n    public static boolean between(@SqlType(\"T\") Slice value, @SqlType(\"T\") Slice min, @SqlType(\"T\") Slice max)\n    {\n        return min.compareTo(value) <= 0 && value.compareTo(max) <= 0;\n    }\n\n    @Description(\"Get the key corresponding to an enum value\")\n    @ScalarFunction(\"enum_key\")\n    @TypeParameter(value = \"T\", boundedBy = VARCHAR_ENUM)\n    @SqlType(StandardTypes.VARCHAR)\n    public static Slice enumKey(@TypeParameter(\"T\") VarcharEnumType enumType, @SqlType(\"T\") Slice value)\n    {\n        Optional<String> key = enumType.getEnumKeyForValue(value.toStringUtf8());\n        if (!key.isPresent()) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format(\"No value '%s' in enum type %s\", value.toStringUtf8(), enumType.getTypeSignature().getBase()));\n        }\n        return utf8Slice(key.get());\n    }\n}\n","sourceCodeStart":143,"sourceCodeEnd":166,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/type/VarcharEnumOperators.java#L143-L166","documentation":"Raised by the enum_key function when the given varchar value does not correspond to any value defined in the varchar enum type T. getEnumKeyForValue returns empty and Presto throws INVALID_FUNCTION_ARGUMENT naming both the value and the enum type.","triggerScenarios":"SELECT enum_key(MyEnumType, 'unknownValue') where the string is not a member of the enum's value set (case mismatch, stale value removed from the enum definition, or typo).","commonSituations":"Enum definitions evolving while data retains old values; case-sensitivity mismatches ('active' vs 'ACTIVE'); data from other systems using codes not registered in the Presto enum type.","solutions":["Check the enum's defined values (via the type metadata/SHOW output) and use an exact, correctly cased value","Update the enum type definition to include the missing value if it is legitimate","Normalize the input string's case/whitespace before calling enum_key","Guard with a membership check or wrap in error-handling logic in the calling code"],"exampleFix":"// before\nSELECT enum_key(status_enum, status_raw) FROM t;\n// after\nSELECT CASE WHEN status_raw IN ('active','inactive','pending') THEN enum_key(status_enum, status_raw) ELSE NULL END FROM t;","handlingStrategy":"validation","validationCode":"-- Presto SQL: check membership before enum_key (list values per your enum definition)\nSELECT * FROM t WHERE value_col IN ('v1','v2','v3'); -- replace with actual enum values","typeGuard":null,"tryCatchPattern":"-- Guard with CASE or catch at the client layer when invoking enum_key\nSELECT CASE WHEN value_col IN ('v1','v2','v3') THEN enum_key(my_enum, value_col) ELSE NULL END FROM t;","preventionTips":["Keep enum type definitions in sync with actual data values","Match case and whitespace exactly; enum lookup is exact","Profile distinct values of the column against the enum before querying","Update enum definitions when new legitimate values appear"],"tags":["presto","enum","invalid-argument","varchar"],"backgroundTag":"invalid-function-arguments","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}