citusdata / citusdata/citus

Expressions on INCLUDE clause cause weird errors on Citus

Open
#4,537 0 comments 0 reactions 0 assignees View on GitHub
error message
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

INCLUDE clause cannot have expressions, PG throws a nice error. However, Citus throws a weird error:

```SQL

CREATE TABLE test_table(key int, jsonb_col jsonb);

CREATE INDEX test_inedx
ON test_table USING btree
((jsonb_col ->> 'some_val'::text) COLLATE pg_catalog."default" ASC NULLS LAST)
include(key,(jsonb_col ->> 'some_other_val'::text));
ERROR: expressions are not supported in included columns

SELECT create_distributed_table('test_table', 'key');

CREATE INDEX test_inedx
ON test_table USING btree
((jsonb_col ->> 'some_val'::text) COLLATE pg_catalog."default" ASC NULLS LAST)
include(key,(jsonb_col ->> 'some_other_val'::text));
ERROR: unrecognized node type: 341
```

The backtrace points to deparser:
```SQL
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x000000010cfbd467 postgres`errstart(elevel=20, filename="ruleutils.c", lineno=9024, funcname="get_rule_expr", domain=0x0000000000000000) at elog.c:263:14
frame #1: 0x000000010cfbf621 postgres`elog_finish(elevel=20, fmt="unrecognized node type: %d") at elog.c:1337:7
frame #2: 0x000000010d08eeb4 postgres`get_rule_expr.cold.1 + 52
frame #3: 0x000000010cf72c56 postgres`get_rule_expr(node=, context=0x00007ffee300bb78, showimplicit=) at ruleutils.c:7846:21
frame #4: 0x000000010cf6e1ca postgres`deparse_expression_pretty(expr=, dpcontext=0x00007f93600172a8, forceprefix=false, showimplicit=, prettyFlags=0, startIndent=0) at ruleutils.c:3244:2
frame #5: 0x000000010dd56046 citus.so`deparse_index_columns(buffer=0x00007ffee300bc80, indexParameterList=0x00007f936001b298, deparseContext=0x00007f93600172a8) at citus_ruleutils.c:834:37
frame #6: 0x000000010dd55f4e citus.so`deparse_shard_index_statement(origStmt=, distrelid=, shardid=, buffer=0x00007ffee300bc80) at citus_ruleutils.c:722:3
frame #7: 0x000000010dd420bc citus.so`CreateIndexTaskList(indexStmt=0x00007f935e09b1b0) at index.c:859:3
frame #8: 0x000000010dd412f1 citus.so`GenerateCreateIndexDDLJob(createIndexStatement=0x00007f935e09b1b0, createI
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.