{"record":{"id":"66319ab94ee0ffd5","repo":"prestodb/presto","slug":"syntax-error-66319a","errorCode":"SYNTAX_ERROR","errorMessage":"Duplicate property found: %s=%s and %s=%s","messagePattern":"Duplicate property found: (.+?)=(.+?) and (.+?)=(.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/NodeUtils.java","lineNumber":48,"sourceCode":"import static java.lang.String.format;\n\npublic class NodeUtils\n{\n    private NodeUtils() {}\n\n    public static List<SortItem> getSortItemsFromOrderBy(Optional<OrderBy> orderBy)\n    {\n        return orderBy.map(OrderBy::getSortItems).orElse(ImmutableList.of());\n    }\n\n    public static Map<String, Expression> mapFromProperties(List<Property> properties)\n    {\n        Map<String, Expression> outputMap = new HashMap<>();\n\n        for (Property property : properties) {\n            String key = property.getName().getValue();\n            if (outputMap.containsKey(key)) {\n                throw new PrestoException(SYNTAX_ERROR, format(\"Duplicate property found: %s=%s and %s=%s\", key, outputMap.get(key), key, property.getValue()));\n            }\n            outputMap.put(key, property.getValue());\n        }\n\n        return ImmutableMap.copyOf(outputMap);\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":56,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/NodeUtils.java#L30-L56","documentation":"This error is thrown by NodeUtils.mapFromProperties when converting a list of Property SQL AST nodes into a map of expression properties. The library throws SYNTAX_ERROR because the same property name appears twice in the source, which would silently lose data if converted to a map. It surfaces while parsing/analyzing DDL statements such as CREATE TABLE ... WITH (...) or CREATE SESSION property lists.","triggerScenarios":"Calling NodeUtils.mapFromProperties with a properties list containing two Property nodes whose getName().getValue() strings are equal, e.g. 'CREATE TABLE t WITH (partitioned_by = ARRAY['a'], location = ..., partitioned_by = ...)'.","commonSituations":"Hand-written DDL with a copy-pasted property; generated SQL templates that repeat a key; programmatic AST construction appending the same property twice.","solutions":["Remove the duplicate property from the SQL statement, keeping only one entry per name","If building the AST programmatically, deduplicate properties by name before calling mapFromProperties","Enable clearer DDL validation upstream so the offending statement is reported with statement text"],"exampleFix":"// before\nCREATE TABLE t WITH (format = 'ORC', format = 'PARQUET')\n// after\nCREATE TABLE t WITH (format = 'PARQUET')","handlingStrategy":"validation","validationCode":"Set<String> seen = new HashSet<>();\nfor (Property p : properties) {\n    if (!seen.add(p.getName().getValue())) {\n        throw new IllegalArgumentException(\"Duplicate property: \" + p.getName().getValue());\n    }\n}","typeGuard":null,"tryCatchPattern":"try { Map<String, Expression> m = NodeUtils.mapFromProperties(props); } catch (PrestoException e) { if (e.getErrorCode().getCode() == SYNTAX_ERROR.toErrorCode().getCode()) { /* surface duplicate key to user */ } else throw e; }","preventionTips":["Deduplicate properties by name before building the AST","In generated SQL, use a Map (not a List) as the source of properties","Lint DDL templates for repeated WITH keys","Write unit tests for property parsing with edge-case inputs"],"tags":["sql","syntax","ddl","presto"],"backgroundTag":"duplicate-map-key","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"}