Skip to content

Commit

Permalink
sql: add telemetry for UDFs with RETURNS TABLE
Browse files Browse the repository at this point in the history
Informs #100226

Release note: None
  • Loading branch information
mgartner committed Apr 3, 2023
1 parent 04a92b6 commit 255121a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/sql/parser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ func (u *sqlSymUnion) showCreateFormatOption() tree.ShowCreateFormatOption {
%type <privilege.TargetObjectType> target_object_type

// User defined function relevant components.
%type <bool> opt_or_replace opt_return_set opt_no
%type <bool> opt_or_replace opt_return_table opt_return_set opt_no
%type <str> param_name func_as
%type <tree.FuncParams> opt_func_param_with_default_list func_param_with_default_list func_params func_params_list
%type <tree.FuncParam> func_param_with_default func_param
Expand Down Expand Up @@ -4500,7 +4500,8 @@ create_extension_stmt:
// } ...
// %SeeAlso: WEBDOCS/create-function.html
create_func_stmt:
CREATE opt_or_replace FUNCTION func_create_name '(' opt_func_param_with_default_list ')' RETURNS opt_return_set func_return_type
CREATE opt_or_replace FUNCTION func_create_name '(' opt_func_param_with_default_list ')'
RETURNS opt_return_table opt_return_set func_return_type
opt_create_func_opt_list opt_routine_body
{
name := $4.unresolvedObjectName().ToFunctionName()
Expand All @@ -4510,11 +4511,11 @@ create_func_stmt:
FuncName: name,
Params: $6.functionParams(),
ReturnType: tree.FuncReturnType{
Type: $10.typeReference(),
IsSet: $9.bool(),
Type: $11.typeReference(),
IsSet: $10.bool(),
},
Options: $11.functionOptions(),
RoutineBody: $12.routineBody(),
Options: $12.functionOptions(),
RoutineBody: $13.routineBody(),
}
}
| CREATE opt_or_replace FUNCTION error // SHOW HELP: CREATE FUNCTION
Expand All @@ -4523,6 +4524,10 @@ opt_or_replace:
OR REPLACE { $$.val = true }
| /* EMPTY */ { $$.val = false }

opt_return_table:
TABLE { return unimplementedWithIssueDetail(sqllex, 100226, "UDF returning TABLE") }
| /* EMPTY */ { $$.val = false }

opt_return_set:
SETOF { $$.val = true}
| /* EMPTY */ { $$.val = false }
Expand Down
10 changes: 10 additions & 0 deletions pkg/sql/parser/testdata/create_function
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,13 @@ CREATE FUNCTION _()
RETURNS INT8
LANGUAGE plpgsql
AS $$_$$ -- identifiers removed

error
CREATE FUNCTION f() RETURNS TABLE 'SELECT 1' LANGUAGE SQL
----
at or near "table": syntax error: unimplemented: this syntax
DETAIL: source SQL:
CREATE FUNCTION f() RETURNS TABLE 'SELECT 1' LANGUAGE SQL
^
HINT: You have attempted to use a feature that is not yet implemented.
See: https://go.crdb.dev/issue-v/100226/

0 comments on commit 255121a

Please sign in to comment.