citusdata / citusdata/citus

bug in create_distributed_function() the arguments are not optional but should be.

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

Description

In the [documentation](https://docs.citusdata.com/en/v10.2/develop/api_udf.html#create-distributed-function) it says that the third argument **colocate_with**, of the **create_distributed_function**, is optional.

> colocate_with: (Optional) When the distributed function reads or writes to a distributed table (or more generally Co-Locating Tables), be sure to name that table using the colocate_with parameter. This ensures that each invocation of the function runs on the worker node containing relevant shards.

However this is not the case:

```
CREATE FUNCTION custom_to_char(date) RETURNS text AS
$$ select to_char($1, 'YYYYMMDD'); $$
LANGUAGE sql immutable;

SELECT create_distributed_function( 'custom_to_char(date)', '$1' );
```

produces this error message:

```
ERROR: cannot distribute the function "custom_to_char" since there is no table to colocate with
HINT: Provide a distributed table via "colocate_with" option to create_distributed_function()
SQL state: 22023
```

Running
PostgreSQL 12.8 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
on Azure Hyperscale,

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.