Skip to content

Commit

Permalink
Defaults args for CREATE FUNCTION (#7197)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitstn committed Jul 29, 2024
1 parent eab45d1 commit f186ded
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ydb/library/yql/sql/pg/pg_sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5420,10 +5420,17 @@ class TExtensionHandler : public IPGParseEvents {
}

bool hasArgNames = false;
ui32 defArgsCount = 0;
for (int i = 0; i < ListLength(value->parameters); ++i) {
auto node = LIST_CAST_NTH(FunctionParameter, value->parameters, i);
hasArgNames = hasArgNames || (node->name != nullptr);
if (node->mode == FUNC_PARAM_IN || node->mode == FUNC_PARAM_DEFAULT) {
if (node->defexpr) {
++defArgsCount;
} else {
Y_ENSURE(!defArgsCount);
}

desc.InputArgNames.push_back(node->name ? node->name : "");
} else if (node->mode == FUNC_PARAM_OUT) {
desc.OutputArgNames.push_back(node->name ? node->name : "");
Expand Down Expand Up @@ -5460,6 +5467,17 @@ class TExtensionHandler : public IPGParseEvents {
}

Builder.CreateProc(desc);
if (defArgsCount) {
Y_ENSURE(!desc.VariadicType);
for (ui32 i = 0; i < defArgsCount; ++i) {
desc.ArgTypes.pop_back();
if (!desc.InputArgNames.empty()) {
desc.InputArgNames.pop_back();
}

Builder.CreateProc(desc);
}
}
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions ydb/library/yql/tests/common/test_framework/yqlrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def res_file_path(name):
'PYTHON_COVERAGE_PREFIX',
'NLG_COVERAGE_FILENAME',
'YQL_EXPORT_PG_FUNCTIONS_DIR',
'YQL_ALLOW_ALL_PG_FUNCTIONS',
]:
if var in os.environ:
env[var] = os.environ[var]
Expand Down Expand Up @@ -266,6 +267,7 @@ def res_file_path(name):
'PYTHON_COVERAGE_PREFIX',
'NLG_COVERAGE_FILENAME',
'YQL_EXPORT_PG_FUNCTIONS_DIR',
'YQL_ALLOW_ALL_PG_FUNCTIONS',
]:
if var in os.environ:
env[var] = os.environ[var]
Expand Down

0 comments on commit f186ded

Please sign in to comment.