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

Tuple objects #372

Closed
pavel-zverkov opened this issue Apr 17, 2023 · 5 comments
Closed

Tuple objects #372

pavel-zverkov opened this issue Apr 17, 2023 · 5 comments

Comments

@pavel-zverkov
Copy link

Describe the bug
clickhouse-driver cannot fulfill the request with tuple function

To Reproduce
For reproduce a table with one or two column is suitable for you.

Queries examples
client.execute('SELECT tuple(column_1) FROM table')
client.execute('SELECT tuple(column_1, column_2) FROM table')
client.execute('SELECT (column_1,) FROM table')
client.execute('SELECT (column_1, column_2) FROM table')

Versions

  • clickhouse-driver == 0.2.5.
  • ClickHouse server version > 22.6.8.35
  • Python > 3.9
@xzkostyan
Copy link
Member

What exception do you have?

In [1]: import clickhouse_driver  
   ...:   
   ...: print(clickhouse_driver.__version__) 
   ...: client = clickhouse_driver.Client.from_url('clickhouse://localhost') 
   ...:  
   ...: print(client.execute('SELECT version()')) 
   ...: print(client.execute('SELECT tuple(number) FROM system.numbers limit 5')) 
   ...: print(client.execute('SELECT tuple(number, number) FROM system.numbers limit 5')) 
   ...:                                                                                                                                                                                       
0.2.5
[('23.3.1.2823',)]
[((0,),), ((1,),), ((2,),), ((3,),), ((4,),)]
[((0, 0),), ((1, 1),), ((2, 2),), ((3, 3),), ((4, 4),)]

@pavel-zverkov
Copy link
Author

Some clarifications

the columns in query must have type 'LowCardinality(string) and table Engine - MergeTree

for one column I have infinite time for script execution
for two column - tuple index out of range

@xzkostyan
Copy link
Member

Please provide snippet (CREATE TABLE, INSERT, SELECT) that throws this error.

@pavel-zverkov
Copy link
Author

pavel-zverkov commented Apr 17, 2023

import clickhouse_driver

print(clickhouse_driver.__version__)
client = clickhouse_driver.Client.from_url('clickhouse://localhost')
print(client.execute('SELECT version()'))

# create table
create_query = '''CREATE TABLE IF NOT EXISTS test_low_cardinality_tuple 
                    (
                        `column_1` LowCardinality(String),
                        `column_2` LowCardinality(String),
                    )
                    ENGINE = MergeTree
                    ORDER BY column_1
                '''
client.execute(create_query)

# insert data
insert_query = 'INSERT INTO test_low_cardinality_tuple (column_1, column_2) VALUES'
VALUES = [('1', '2'), ('3', '4')]
client.execute(insert_query, VALUES)

# bad queries
test_query_1 = 'SELECT tuple(column_1) FROM test_low_cardinality_tuple'
test_query_2 = 'SELECT tuple(column_1, column_2) FROM test_low_cardinality_tuple'

# drop query
drop_query = 'DROP TABLE IF EXISTS test_low_cardinality_tuple'

# testing
try:
    print(client.execute(test_query_1))
    client.execute(drop_query)
except Exception as e:
    print(str(e))
    client.execute(drop_query)`

@xzkostyan
Copy link
Member

Fix is merged into latest master and will be included into next release.

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

2 participants