Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL UDFs #3994

Closed
BohuTANG opened this issue Jan 26, 2022 · 16 comments
Closed

SQL UDFs #3994

BohuTANG opened this issue Jan 26, 2022 · 16 comments
Assignees
Labels
A-query Area: databend query community-take good first issue Category: good first issue
Milestone

Comments

@BohuTANG
Copy link
Member

  • Scalar SQL UDFs (already done)

Databend already have the scalar UDFs:

CREATE FUNCTION mean2number AS (x, y) -> (x + y) / 2;
SELECT mean2number(150, 250);
+-------------------+
| ((150 + 250) / 2) |
+-------------------+
|               200 |
+-------------------+
  • Tabular SQL UDFs (UDTFs)(TODO)

A user-defined table functions can apply to a sql query and returns 0, 1 or multi-rows, each result contains 1 or more columns.
A snow style UDTFs:

create function sum_range_func(l int, r int)
  returns table (x integer)
  as 'select sum(a) from test where a > l and a < r'
  ;
  
select * from table(sum_range_func(1,9));

Reference:
https://docs.snowflake.com/en/developer-guide/udf/sql/udf-sql-tabular-functions.html

@BohuTANG BohuTANG added A-query Area: databend query good first issue Category: good first issue labels Jan 26, 2022
@GrapeBaBa
Copy link
Contributor

/assignme

@wangzhen11aaa
Copy link
Contributor

wangzhen11aaa commented Feb 3, 2022

https://github.com/ClickHouse/ClickHouse/pull/23978/commits
We can refer to this.

@BohuTANG
Copy link
Member Author

BohuTANG commented Feb 4, 2022

https://github.com/ClickHouse/ClickHouse/pull/23978/commits We can refer to this.

It looks like Scalar UDF in databend, we have implemented it:
https://github.com/datafuselabs/databend/blob/8452db7e49afbcef3e9b21539bb22b9ab0c3e697/tests/suites/0_stateless/05_ddl/05_0010_ddl_create_udf.sql

The purpose of this issue is to implement Tabular SQL UDFs.

@GrapeBaBa
Copy link
Contributor

@BohuTANG @wangzhen11aaa Any other database open sourced support tabular function?

@wangzhen11aaa
Copy link
Contributor

wangzhen11aaa commented Feb 8, 2022

@BohuTANG @wangzhen11aaa Any other database open sourced support tabular function?

I think this article will give you some idea, This is a very good example.
https://docs.snowflake.com/en/sql-reference/functions-table.html

@BohuTANG
Copy link
Member Author

BohuTANG commented Feb 8, 2022

@BohuTANG @wangzhen11aaa Any other database open sourced support tabular function?

I haven't seen yet, maybe have but it's not important for this issue :)

@BohuTANG
Copy link
Member Author

BohuTANG commented Feb 8, 2022

BTW, databend already used tabular function: select * from numbers(10), it accepts an argument and returning blocks.

@GrapeBaBa
Copy link
Contributor

BTW, databend already used tabular function: select * from numbers(10), it accepts an argument and returning blocks.

Cool. Let me check it.

@wangzhen11aaa
Copy link
Contributor

BTW, databend already used tabular function: select * from numbers(10), it accepts an argument and returning blocks.
Is the following expression ture?
Tabular function = Table Function?

@BohuTANG
Copy link
Member Author

Mostly the same.

@wangzhen11aaa
Copy link
Contributor

Mostly the same.

Thanks

@BohuTANG
Copy link
Member Author

Update:
Tabular SQL UDFs looks like a deep version of view #4610

@GrapeBaBa
Copy link
Contributor

Update: Tabular SQL UDFs looks like a deep version of view #4610

@BohuTANG I prepare starting this task, what is your latest suggestion here after view feature merged.

@BohuTANG
Copy link
Member Author

@GrapeBaBa
Cool, Thanks for taking, my suggestion is: just do it :D

@Xuanwo Xuanwo added this to the v0.8 milestone May 20, 2022
@BohuTANG
Copy link
Member Author

BohuTANG commented Jun 2, 2022

Hi, @GrapeBaBa

How is this going? :)
Spill a new issue for the tabular UDF: #5731, and welcome to take.
This issue will be closed soon.

@GrapeBaBa
Copy link
Contributor

Hi, @GrapeBaBa

How is this going? :) Spill a new issue for the tabular UDF: #5731, and welcome to take. This issue will be closed soon.

will do it.

@BohuTANG BohuTANG closed this as completed Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query Area: databend query community-take good first issue Category: good first issue
Projects
None yet
Development

No branches or pull requests

5 participants