{"record":{"id":"447211543bcb0143","repo":"prestodb/presto","slug":"invalid-table-property-447211","errorCode":"INVALID_TABLE_PROPERTY","errorMessage":"The property of %s is required for table engine %s","messagePattern":"The property of (.+?) is required for table engine (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-clickhouse/src/main/java/com/facebook/presto/plugin/clickhouse/ClickHouseClient.java","lineNumber":773,"sourceCode":"        String columnTypeMapping = toWriteMapping(column.getType());\n        if (column.isNullable()) {\n            builder.append(\"Nullable(\").append(columnTypeMapping).append(\")\");\n        }\n        else {\n            builder.append(columnTypeMapping);\n        }\n        return builder.toString();\n    }\n\n    protected String createTableSql(RemoteTableName remoteTableName, List<String> columns, ConnectorTableMetadata tableMetadata)\n    {\n        ImmutableList.Builder<String> tableOptions = ImmutableList.builder();\n        Map<String, Object> tableProperties = tableMetadata.getProperties();\n        ClickHouseEngineType engine = ClickHouseTableProperties.getEngine(tableProperties);\n        tableOptions.add(\"ENGINE = \" + engine.getEngineType());\n        if (engine == MERGETREE && formatProperty(ClickHouseTableProperties.getOrderBy(tableProperties)).equals(Optional.empty())) {\n            // order_by property is required\n            throw new PrestoException(INVALID_TABLE_PROPERTY,\n                    format(\"The property of %s is required for table engine %s\", ORDER_BY_PROPERTY, engine.getEngineType()));\n        }\n        formatProperty(ClickHouseTableProperties.getOrderBy(tableProperties)).ifPresent(value -> tableOptions.add(\"ORDER BY \" + value));\n        formatProperty(ClickHouseTableProperties.getPrimaryKey(tableProperties)).ifPresent(value -> tableOptions.add(\"PRIMARY KEY \" + value));\n        formatProperty(ClickHouseTableProperties.getPartitionBy(tableProperties)).ifPresent(value -> tableOptions.add(\"PARTITION BY \" + value));\n        ClickHouseTableProperties.getSampleBy(tableProperties).ifPresent(value -> tableOptions.add(\"SAMPLE BY \" + value));\n\n        return format(\"CREATE TABLE %s (%s) %s\", quoted(remoteTableName), join(\", \", columns), join(\" \", tableOptions.build()));\n    }\n\n    /**\n     * format property to match ClickHouse create table statement\n     *\n     * @param properties property will be formatted\n     * @return formatted property\n     */\n    private Optional<String> formatProperty(List<String> properties)\n    {","sourceCodeStart":755,"sourceCodeEnd":791,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-clickhouse/src/main/java/com/facebook/presto/plugin/clickhouse/ClickHouseClient.java#L755-L791","documentation":"PrestoException (INVALID_TABLE_PROPERTY) thrown when creating a ClickHouse table with engine=MergeTree without the required order_by table property. ClickHouse's MergeTree family requires an ORDER BY expression; the connector enforces this at DDL time before issuing CREATE TABLE.","triggerScenarios":"CREATE TABLE … ENGINE=MergeTree (or engine='merge_tree') with no order_by property in WITH (...); CTAS statements where table properties omit order_by.","commonSituations":"Migrating DDL from plain ClickHouse SQL where ORDER BY appears inline but the Presto connector requires it as a table property; copying example DDL that omitted WITH properties; forgetting order_by when defaulting engine to merge_tree.","solutions":["Add order_by to the WITH clause: ENGINE=merge_tree, order_by='(...)' or a single column name.","Choose a different engine (e.g. Log/TinyLog) if ordering is not needed.","Include order_by in any CTAS/automation templates that create MergeTree tables.","Also set primary_key consistent with the order_by prefix if desired."],"exampleFix":"-- before\nCREATE TABLE clickhouse.analytics.events (ts DateTime, id bigint)\nWITH (engine = 'merge_tree');\n-- after\nCREATE TABLE clickhouse.analytics.events (ts DateTime, id bigint)\nWITH (engine = 'merge_tree', order_by = ARRAY['ts'], primary_key = ARRAY['ts']);","handlingStrategy":"validation","validationCode":"Map<String, Object> props = metadata.getProperties();\nif (\"merge_tree\".equalsIgnoreCase(String.valueOf(props.getOrDefault(\"engine\", \"\")))\n        && !props.containsKey(\"order_by\")) {\n    throw new IllegalArgumentException(\"engine merge_tree requires the order_by table property\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    createTable(...);\n} catch (PrestoException e) {\n    if (e.getMessage().contains(\"is required for table engine\")) {\n        // add order_by to table properties and retry\n    }\n    throw e;\n}","preventionTips":["Always include order_by in DDL templates for MergeTree tables.","Centralize table-creation helpers that inject required properties.","Review ClickHouseTableProperties docs before writing WITH clauses.","Set primary_key to a prefix of order_by when applicable."],"tags":["clickhouse","ddl","table-properties","mergetree"],"backgroundTag":"missing-required-table-property","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"}