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

Trailing spaces break get_inner_columns_with_types #385

Open
bryzgaloff opened this issue Jul 24, 2023 · 0 comments
Open

Trailing spaces break get_inner_columns_with_types #385

bryzgaloff opened this issue Jul 24, 2023 · 0 comments

Comments

@bryzgaloff
Copy link

bryzgaloff commented Jul 24, 2023

Example of a wrong behaviour

get_inner_columns_with_types function (from clickhouse_driver.columns.util module) returns a wrong value when input spec argument has a trailing space character. For example:

  • get_inner_columns_with_types('test String') (no trailing space) returns [('test', 'String')] which is correct.
  • but get_inner_columns_with_types('test String ') (with a trailing space) returns [('test String', '')] (no type is detected) which is incorrect.

Real life example for trailing whitespace characters:

ch_client.execute(
    external_tables=[{
        'name': 'ext',
        'structure': [('nested_field', '''Nested(
            test String
        )''')],  # here trailing whitespaces appear

Possible solution

Maybe a simple spec.rstrip() should help. At least it helps when calling get_inner_columns_with_types('test String '.rstrip()) :)

As a part of a fix, I would also recommend replace elif x == ' ': with elif x.isspace()::

Versions

clickhouse_driver version is 0.2.6

@bryzgaloff bryzgaloff changed the title Trailing whitespaces break get_inner_columns_with_types Trailing spaces break get_inner_columns_with_types Jul 25, 2023
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

No branches or pull requests

1 participant