When doing SELECT * FROM test_table;
inside clickhouse-client I get N rows as expected, but only N-2 when doing engine.execute('SELECT * FROM test_table;')
from python code that uses sqlalchemy.
Steps to reproduce:
- clickhouse-server is running on localhost.
- The following commands are executed in clickhouse-client:
CREATE TABLE test_table (id INTEGER, created Date) ENGINE = MergeTree(created, (id), 8192);
INSERT INTO test_table (id, created) VALUES (1, 11345678);
INSERT INTO test_table (id, created) VALUES (2, 12345678);
INSERT INTO test_table (id, created) VALUES (3, 13345678);
INSERT INTO test_table (id, created) VALUES (4, 14345678);
SELECT * FROM test_table;
Results:
SELECT *
FROM test_table
┌─id─┬────created─┐
│ 4 │ 2106-02-07 │
└────┴────────────┘
┌─id─┬────created─┐
│ 3 │ 2084-08-20 │
└────┴────────────┘
┌─id─┬────created─┐
│ 2 │ 2038-03-15 │
└────┴────────────┘
┌─id─┬────created─┐
│ 1 │ 1991-10-08 │
└────┴────────────┘
4 rows in set. Elapsed: 0.004 sec.
Okay, 4 rows as expected.
- The following python script is executed:
from sqlalchemy import create_engine
connection_string = 'clickhouse://default:@localhost/default'
engine = create_engine(connection_string)
result = list(engine.execute('SELECT * FROM test_table;'))
print(len(result))
print(result)
Results:
2
[('4', '2106-02-07'), ('2', '2038-03-15')]
Definitely not as expected. So, what is going on here?
sqlalchemy version: 1.3.11
clickhouse version (both server and client): 19.17.4.11