Skip to content

Using validation function instead of manual validation for getReturnTypeImpl - #97672

Merged
scanhex12 merged 22 commits into
ClickHouse:masterfrom
MaxMaz111:feat-replace-manual-validation
Mar 6, 2026
Merged

scanhex12 merged 22 commits into
ClickHouse:masterfrom
MaxMaz111:feat-replace-manual-validation

Conversation

@MaxMaz111

@MaxMaz111 MaxMaz111 commented Feb 22, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category:

  • Improvement

Changelog entry

getReturnTypeImpl for tupleConcat now checks input using a validateFunctionArgumentsWithVariadics instead of doing it manually.

this closes #67447


Note

Medium Risk
Touches getReturnTypeImpl validation across many built-in functions; behavior should be equivalent but could subtly change accepted argument combinations and error messages/codes, affecting compatibility.

Overview
Standardizes function argument validation by replacing ad-hoc checks in getReturnTypeImpl with validateFunctionArguments/validateFunctionArgumentsWithVariadics across a set of functions (e.g., file, now, tupleConcat, JSON/string/random/introspection helpers).

Adds small reusable type predicates (notably isLowCardinalityType in FunctionHelpers, plus local helpers like isStringOrNull/isDateOrDateTime) to express expected argument types, improving consistency and reducing duplicated error-handling logic.

Written by Cursor Bugbot for commit 9ccf139. This will update automatically on new commits. Configure here.

@CLAassistant

CLAassistant commented Feb 22, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@MaxMaz111 MaxMaz111 changed the title Moved tupleConcat to general validation Using validation function instead of manual validation for getReturnTypeImpl Feb 22, 2026
@scanhex12 scanhex12 added the can be tested Allows running workflows for external contributors label Feb 22, 2026
@clickhouse-gh

clickhouse-gh Bot commented Feb 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9ccf139]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Feb 22, 2026
Comment thread src/Functions/FunctionFile.cpp Resolved
Comment thread src/Functions/lowCardinalityIndices.cpp Resolved
@scanhex12 scanhex12 self-assigned this Mar 5, 2026
Comment thread src/Functions/FunctionFile.cpp Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread src/Functions/evalMLMethod.cpp Resolved

@scanhex12 scanhex12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

if (!isString(arguments[0]))
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of the first argument of function {}", arguments[0]->getName(), getName());
FunctionArgumentDescriptors mandatory_args{
{"s", &isString, nullptr, "String"},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

's' and 'c' seems strange, how did you get such names?

@MaxMaz111 MaxMaz111 Mar 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As far i as i remember, all the arguments names are from FunctionDocumentation::Arguments listed below

@scanhex12
scanhex12 enabled auto-merge March 6, 2026 21:49
@scanhex12
scanhex12 added this pull request to the merge queue Mar 6, 2026
Merged via the queue into ClickHouse:master with commit 686f7ab Mar 6, 2026
146 checks passed
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 6, 2026
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request Mar 11, 2026
PR ClickHouse#97672 replaced manual argument validation with `validateFunctionArguments`
in 21 function files. The following functions had no existing tests for their
error paths (wrong argument types):

- `appendTrailingCharIfAbsent`
- `monthName`
- `conv`
- `lowCardinalityIndices` / `lowCardinalityKeys`
- `randomPrintableASCII`
- `randomString`
- `ngrams` (uses `BAD_ARGUMENTS` instead of `ILLEGAL_TYPE_OF_ARGUMENT`)
- `dynamicType`

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
github-merge-queue Bot pushed a commit that referenced this pull request Mar 16, 2026
…ests

Add error-path tests for functions refactored in PR #97672
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace manual function input validation by validateFunctionArguments

4 participants