ClickHouse / ClickHouse/odbc-bridge
Query fails when the external ODBC table has an unusual character (�)
- Dominant language
- C++
- Stars
- 4
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
**Describe what's wrong**
CH query fails while getting data from SQL Server table using ODBC driver (SQL Server ODBC 18).
```
HTTP status code: 500 Internal Server Error, body: �
std::exception. Code: 1001, type: std::range_error, e.what() = wstring_convert: to_bytes error,.
(RECEIVED_ERROR_FROM_REMOTE_IO_SERVER) (version 22.3.2.1)
, server ClickHouseNode(addr=http:.......:8123, db=default)@
```
Is this the expected behavior?
SQL Server jdbc and .Net drivers process these values with no issues.
**Does it reproduce on a recent release?**
Yes
**How to reproduce**
The CH table:
```sql
CREATE TABLE external_table
(
`pk_id` Int64,
`comment` Nullable(String)
)
ENGINE = ODBC('DSN=SQL_SERVER; Database=externalDatabase;', 'dbo', 'table');
```
SQL Server table
```sql
CREATE TABLE dbo.table (
[PK_id] BIGINT NOT NULL,
[comment] NVARCHAR (4000) NULL
);
-- test data with problematic character (`3DD8`)
INSERT INTO dbo.table (pk_id, comment)
SELECT 1,
CONVERT (NVARCHAR (MAX), 0x43006F006D00700061006E00790020004D0069007300730069006F006E002000530074006100740065006D0065006E007400200077006100730020006300680061006E006700650064002E0020004200650066006F00720065003A00200057006F0072006B0069006E006700200069006E0020006100200075006E006900710075006500200077006F0072006B0020007300740079006C0065002C0020006200610073006500640020006F006E00200063006F00720065002000760061006C00750065007300200066006F00720020006F0075007200200063006C00690065006E00740027007300200073007500630063006500730073002E0020006F00750072002000330020007000720069006E006300690070006C00650073000A003DD82E002E002E002000410066007400650072003A00200057006F0072006B0069006E006700200069006E0020006100200075006E006900710075006500200077006F0072006B0020007300740079006C0065002C0020006200610073006500640020006F006E00200063006F00720065002000760061006C00750065007300200066006F00720020006F0075007200200063006C00690065006E00740027007300200073007500630063006500730073002E0020006F00750072002000330020007000720069006E006300690070006C00650073000A003DD82E002E002E00);
```
An unusual character in the SQL Server table:

**Expected behavior**
All kinds of characters should be processed as usual.
Contributor guide
Assessment
This issue has not been assessed yet.