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

udf: allow strict UDF with no arguments #96328

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/udf
Original file line number Diff line number Diff line change
Expand Up @@ -2968,3 +2968,13 @@ distribution: local
vectorized: true
·
• create function

# Regression test for #96326. Strict UDFs with no arguments should not error
# while being called.
statement ok
CREATE FUNCTION f96326() RETURNS INT LANGUAGE SQL IMMUTABLE STRICT AS 'SELECT 1';

query I
SELECT f96326();
----
1
2 changes: 1 addition & 1 deletion pkg/sql/opt/optbuilder/scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ func (b *Builder) buildUDF(
//
// CASE WHEN arg1 IS NULL OR arg2 IS NULL OR ... THEN NULL ELSE udf() END
//
if !o.CalledOnNullInput {
if !o.CalledOnNullInput && len(args) > 0 {
var anyArgIsNull opt.ScalarExpr
for i := range args {
// Note: We do NOT use a TupleIsNullExpr here if the argument is a
Expand Down