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: move NullableArgs function property to overload level #83732

Conversation

chengxiong-ruan
Copy link
Contributor

Currently we only have builtins, and that all overloads of a
same function name share function properties. However, we're
going to support user defined functions whose properties can
vary as how users define them. So we need to move any property
that's relevant to UDF to overload level. Currently, NullableArgs
is the only one matters.

Release note: None.

@chengxiong-ruan chengxiong-ruan requested a review from a team July 1, 2022 22:45
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@chengxiong-ruan chengxiong-ruan changed the title sql: move NullableArgs function property to overload level (WIP) sql: move NullableArgs function property to overload level Jul 2, 2022
@chengxiong-ruan chengxiong-ruan force-pushed the move-nullableargs-to-overload-level branch 3 times, most recently from 5d3a5ab to fd25e76 Compare July 2, 2022 18:47
@chengxiong-ruan chengxiong-ruan changed the title (WIP) sql: move NullableArgs function property to overload level sql: move NullableArgs function property to overload level Jul 5, 2022
@chengxiong-ruan chengxiong-ruan marked this pull request as ready for review July 5, 2022 17:27
@chengxiong-ruan chengxiong-ruan requested a review from a team July 5, 2022 17:27
@chengxiong-ruan chengxiong-ruan requested review from a team as code owners July 5, 2022 17:27
@chengxiong-ruan
Copy link
Contributor Author

CI failures seems not relevant

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

LGTM though please do consider renaming unNullable

)
}

func makeDefaultAggOverloadWithReturnType(
in []*types.T, retType tree.ReturnTyper, f eval.AggregateOverload, info string,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is starting to feel like enough arguments that it'd be more readable to make a struct

Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to not act on this one.

@@ -1071,17 +1071,27 @@ func (expr *FuncExpr) TypeCheck(
return nil, pgerror.Wrapf(err, pgcode.InvalidParameterValue, "%s()", def.Name)
}

var nullableArgFns []overloadImpl
var unNullableArgFns []overloadImpl
Copy link
Contributor

Choose a reason for hiding this comment

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

What about notNullableArgsFn?

Comment on lines 1077 to 1081
if f.(*Overload).NullableArgs {
nullableArgFns = append(nullableArgFns, f)
continue
}
unNullableArgFns = append(unNullableArgFns, f)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this seems like a nice place for an else

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @chengxiong-ruan, and @rafiss)


pkg/sql/sem/builtins/aggregate_builtins.go line 654 at r1 (raw file):

	return b
}
func makeDefaultAggOverload(

should we name this makeImmutableAggOverload (and ditto below)?

@chengxiong-ruan chengxiong-ruan force-pushed the move-nullableargs-to-overload-level branch from fd25e76 to dceae64 Compare July 6, 2022 18:54
Copy link
Contributor Author

@chengxiong-ruan chengxiong-ruan left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @chengxiong-ruan, and @rafiss)


pkg/sql/sem/builtins/aggregate_builtins.go line 654 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

should we name this makeImmutableAggOverload (and ditto below)?

yes, good point, changed to that.


pkg/sql/sem/tree/type_check.go line 1075 at r1 (raw file):

Previously, ajwerner wrote…

What about notNullableArgsFn?

done, sorry for the bad naming


pkg/sql/sem/tree/type_check.go line 1081 at r1 (raw file):

Previously, ajwerner wrote…

nit: this seems like a nice place for an else

done

Currently we only have builtins, and that all overloads of a
same function name share function properties. However, we're
going to support user defined functions whose properties can
vary as how users define them. So we need to move any property
that's relevant to UDF to overload level. Currently, `NullableArgs`
is the only one matters.

Release note: None.
@chengxiong-ruan chengxiong-ruan force-pushed the move-nullableargs-to-overload-level branch from dceae64 to 7e6d300 Compare July 7, 2022 13:49
@chengxiong-ruan
Copy link
Contributor Author

TFTR!
bors r+

@craig
Copy link
Contributor

craig bot commented Jul 7, 2022

Build succeeded:

@craig craig bot merged commit e67e47f into cockroachdb:master Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants