ClickHouse / ClickHouse/clickhouse-odbc
Exception when trying to insert rows with async_insert=1 setting using pyodbc
- Dominant language
- C
- Stars
- 285
- Forks
- 105
- Avg merge
- 3h 56m
- Merged PRs (30d)
- 3
Description
When trying to insert rows (even a single row) into table using `pyodbc` Python package with user-level `async_insert=1` setting or with `SETTINGS async_insert=1` inside the query, I receive the following error:
```
DB::Exception: Substitution `odbc_positional_1` is not set: While executing WaitForAsyncInsert.
(UNKNOWN_QUERY_PARAMETER) (version 23.3.5.9 (official build))
```
Everything works fine when `async_insert=0` or when using `isql` utility from unixODBC.
OS: Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-76-generic x86_64)
ODBC Drivers Manager: unixODBC 2.3.9-5
ClickHouse ODBC driver: 1.2.1.20220905 (built from sources according to [this doc](https://cloud.yandex.ru/docs/managed-clickhouse/operations/connect#odbc))
ClickHouse server: 23.3
Python: 3.8.17
Pyodbc: 4.0.39
There is also a more general question if it is possible to make bulk inserts with `pyodbc` + `clickhouse-odbc` driver, because it seems like `pyodbc` makes inserts row by row, according to logs. It takes 20 seconds to insert 1000 rows into table with 3 columns (Int64, Float64 and String types) when using `pyodbc.Cursor.executemany()` even with `fast_executemany=True`.
Contributor guide
Research direction
Start with a minimal pyodbc Cursor.executemany() reproduction using SETTINGS async_insert=1, then compare it with async_insert=0 and the isql utility. Trace the odbc_positional_1 error while executing WaitForAsyncInsert and verify whether the bulk-insert behavior and async insert failure are resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100