apache / apache/datafusion

Unable to determine return type for function `ArrayFill`

Open
#6,779 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Describe the bug

`ArrayFill` function can return lists with different dimensions:
```
postgres=# select array_fill(a, b) from fills;
array_fill
-----------------------------------
{{2,2}}
{5,5,5,5,5,5,5}
{{{{1}}}}
{{4,4,4},{4,4,4},{4,4,4},{4,4,4}}
(4 rows)
```

The standard `return_type` function cannot determine the type for 'dynamic' functions. because it prefers to assign one type to the whole column and does not take into account their arguments.

### To Reproduce

_No response_

### Expected behavior

_No response_

### Additional context

About `array_fill` function: https://www.postgresql.org/docs/current/functions-array.html.

Contributor guide

Open the contributing guide

Research direction

Start by examining DataFusion's handling of the PostgreSQL-compatible array_fill function and the standard return_type function. Trace how function arguments are used when determining the result type, using the issue's examples of arrays with different dimensions. Done means array_fill calls receive the correct return type instead of one type being assigned to the whole column.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, rust
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.