{"record":{"id":"30eb4e4db4f6c509","repo":"prestodb/presto","slug":"invalid-function-argument-30eb4e","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"Unknown stemmer language: ","messagePattern":"Unknown stemmer language: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/scalar/WordStemFunction.java","lineNumber":95,"sourceCode":"\n    @Description(\"returns the stem of a word in the English language\")\n    @ScalarFunction\n    @LiteralParameters(\"x\")\n    @SqlType(\"varchar(x)\")\n    public static Slice wordStem(@SqlType(\"varchar(x)\") Slice slice)\n    {\n        return wordStem(slice, new EnglishStemmer());\n    }\n\n    @Description(\"returns the stem of a word in the given language\")\n    @ScalarFunction\n    @LiteralParameters(\"x\")\n    @SqlType(\"varchar(x)\")\n    public static Slice wordStem(@SqlType(\"varchar(x)\") Slice slice, @SqlType(\"varchar(2)\") Slice language)\n    {\n        Supplier<SnowballStemmer> stemmer = STEMMERS.get(language);\n        if (stemmer == null) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, \"Unknown stemmer language: \" + language.toStringUtf8());\n        }\n        return wordStem(slice, stemmer.get());\n    }\n\n    private static Slice wordStem(Slice slice, SnowballStemmer stemmer)\n    {\n        stemmer.setCurrent(slice.toStringUtf8());\n        return stemmer.stem() ? utf8Slice(stemmer.getCurrent()) : slice;\n    }\n}\n","sourceCodeStart":77,"sourceCodeEnd":106,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/scalar/WordStemFunction.java#L77-L106","documentation":"stem(varchar, varchar) applies a Snowball stemmer for a specific two-character language code. The engine keeps a fixed map (STEMMERS) of supported languages; if the supplied language string is not a key in that map, it throws INVALID_FUNCTION_ARGUMENT. The language argument must be one of the supported ISO-639-1 codes (e.g. 'en', 'de', 'fr', 'es', 'it', 'ru').","triggerScenarios":"Calling stem(text, 'english'), stem(text, 'EN'), stem(text, 'xx'), or any code not in the STEMMERS map — including full language names, wrong case, or codes for languages without a registered Snowball stemmer.","commonSituations":"Users pass human-readable language names instead of 2-letter codes; country-vs-language code mix-ups (e.g. 'us' instead of 'en'); uppercase codes from config files; unsupported languages like 'zh' that have no Snowball stemmer in the map.","solutions":["Use a supported two-letter lowercase code, e.g. stem('running', 'en').","Normalize the input: lower(substr(lang, 1, 2)) before calling stem.","Check the supported language list in WordStemFunction (the STEMMERS map) and pick from it.","For unsupported languages (e.g. Chinese), use a different tokenization/analysis path rather than stem()."],"exampleFix":"// before\nSELECT stem('running', 'ENGLISH');\n// after\nSELECT stem('running', 'en');","handlingStrategy":"validation","validationCode":"-- restrict language to supported 2-letter codes\nSELECT CASE WHEN lang IN ('en','de','fr','es','it','pt','ru','nl','sv','da','no','fi','hu','ro','tr') THEN stem(txt, lang) ELSE stem(txt, 'en') END;","typeGuard":"boolean isSupportedStemmerLanguage(String lang) {\n    return lang != null && lang.length() == 2 && lang.equals(lang.toLowerCase(java.util.Locale.ROOT));\n}","tryCatchPattern":"try { stemmed = stem(txt, lang); } catch (PrestoException e) { if (e.getErrorCode().getName().equals(\"INVALID_FUNCTION_ARGUMENT\")) { stemmed = txt; } else { throw e; } }","preventionTips":["Always pass lowercase two-letter ISO-639-1 codes, never full language names.","Normalize language config values with lower() and substr(lang, 1, 2).","Consult the STEMMERS map in WordStemFunction for the supported set.","Fall back to 'en' or raw text for languages without a Snowball stemmer."],"tags":["presto","sql","text","stemmer","snowball"],"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"}