Skip to content

Try to treat input values as enum id in tsv/scv#16834

Merged
alexey-milovidov merged 3 commits intoClickHouse:masterfrom
Avogar:enum-as-num
Nov 12, 2020
Merged

Try to treat input values as enum id in tsv/scv#16834
alexey-milovidov merged 3 commits intoClickHouse:masterfrom
Avogar:enum-as-num

Conversation

@Avogar
Copy link
Copy Markdown
Member

@Avogar Avogar commented Nov 10, 2020

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add a possibility to input enum value as it's id in TSV and CSV formats by default.

Detailed description / Documentation draft:
Now in TSV and CSV input formats it's possible to write enum id instead of enum name. To avoid ambiguity (enum name could consist digits), first we try to match input string to enum name, if we fail and input string is number, than we try to match this number to enum id.

@robot-clickhouse robot-clickhouse added doc-alert pr-feature Pull request with new product feature labels Nov 10, 2020
bool isStringNumber(StringRef str)
{
for (size_t i = 0; i != str.size; ++i)
if (!isdigit(str.data[i]))
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.

This function depends on locale that may give surprising results.
Let's replace to isNumericASCII from StringUtils.

}

FieldType getValue(StringRef field_name) const
FieldType getValue(StringRef field_name, bool try_treat_as_id=false) const
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.

Whitespace: bool try_treat_as_id = false

@alexey-milovidov alexey-milovidov self-assigned this Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants