Skip to content

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Oct 1, 2025

Which issue does this PR close?

  • Closes #.

Rationale for this change

Internlly at InfluxData, we are evaluating using CREATE FUNCTION but when I was providing links to the docs, it was a little sparse and unclear what was supported.

I think some documentation would make this functionality a little easier to find and use.

What changes are included in this PR?

Add some documentation and links

Are these changes tested?

By CI and I rendered them locally:

Screenshot 2025-10-01 at 8 37 50 AM

Are there any user-facing changes?

I also added Debug and Clone to RegisterFunction for consistency

@github-actions github-actions bot added logical-expr Logical plan and expressions core Core DataFusion crate labels Oct 1, 2025
@alamb alamb added the documentation Improvements or additions to documentation label Oct 1, 2025
@alamb alamb changed the title Alamb/function facotry docs docs: Improve documentation for FunctionFactory / CREATE FUNCTION Oct 1, 2025
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Oct 1, 2025
@alamb alamb requested a review from milenkovicm October 1, 2025 20:34
@alamb
Copy link
Contributor Author

alamb commented Oct 1, 2025

@milenkovicm since you added this feature initially as I recall, I wonder if you could review this documentation improvement PR?

Copy link
Contributor

@milenkovicm milenkovicm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alamb documentation looks much better now

/// and interact with [SessionState] to registers new udf, udaf or udwf.
/// Interface for handling `CREATE FUNCTION` statements and interacting with
/// [SessionState] to create and register functions ([`ScalarUDF`],
/// [`AggregateUDF`], [`WindowUDF`], and [`TableFunctionImpl`]) dynamically.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried ScalarUDF, and AggregateUDF but never WindowUDF nor TableFunction, I guess users can plug-in whatever they want here

@milenkovicm
Copy link
Contributor

A shameless plug 😃 🔌 I have a few more working examples if they are going to help with the evaluation of functionality in InfluxData.

/// ```sql
/// CREATE FUNCTION f1(BIGINT)
/// RETURNS BIGINT
/// RETURN $1 + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one note, not related to this PR, it would be great if we could use variable names instead of $1 and support default values, last time i've tried it did not work

CREATE FUNCTION our_add(A BIGINT DEFAULT 3, B BIGINT DEFAULT 1)
        RETURNS BIGINT
        RETURN $A - $B

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-authored-by: Marko Milenković <milenkovicm@users.noreply.github.com>
@milenkovicm milenkovicm added this pull request to the merge queue Oct 2, 2025
Merged via the queue into apache:main with commit 71512e6 Oct 2, 2025
28 checks passed
@milenkovicm
Copy link
Contributor

I've merged this, thanks @alamb, great improvement

@alamb alamb deleted the alamb/function_facotry_docs branch October 2, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants