datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

suggest add table function `generate_series` and change the results of current version

Open l1t1 opened this issue 1 year ago • 2 comments

Is your feature request related to a problem or challenge?

as https://github.com/apache/arrow-datafusion/discussions/9315 mentioned, generate_series is alias of range, it's result does not include the upper bound. it results the problem of Portability from other DBMS.

Describe the solution you'd like

the result of generate_series is same as that of postgresql, the range() funciton keeps the current result

 select generate_series(1,3);
 generate_series
-----------------
               1
               2
               3

select * from generate_series(1,3);
 generate_series
-----------------
               1
               2
               3

Describe alternatives you've considered

No response

Additional context

No response

l1t1 avatar Feb 23 '24 04:02 l1t1

databend's numbers function + 1 is similar with generate_series

ctx.sql("select number+1 from numbers(3)")
┌──────────────┐
│ (number + 1) │
│    UInt64    │
├──────────────┤
│            1 │
│            2 │
│            3 │
└──────────────┘

l1t1 avatar Feb 23 '24 13:02 l1t1

I'm just wondering what is the purpose of datafusion to design in such a way. If this feature is needed, I can do this one.

Lordworms avatar Feb 24 '24 14:02 Lordworms

Here is the duckdb syntax: https://duckdb.org/docs/sql/functions/nested.html#range-functions

It looks to me like generate_series and range can be both scalar functions (return list) or table functions (return a table)

alamb avatar Feb 26 '24 18:02 alamb

I think we should follow postgres or duckdb's syntax

alamb avatar Feb 26 '24 18:02 alamb

take

Lordworms avatar Feb 27 '24 00:02 Lordworms