ClickHouse / clickhouse-odbc

ODBC driver for ClickHouse

Home Page:https://clickhouse.tech

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OracleDB read data from ClickHouse via clickhouse-odbc error because of 2 long columns.

UnamedRus opened this issue · comments

OracleDB doesn't allow to have more than 1 LONG column (It's big string datatype in Oracle)

https://stackoverflow.com/questions/11646124/how-i-can-create-a-table-having-two-long-columns

And for

INSERT INTO oracle_table SELECT * FROM clickhouse_table

OracleDB run query to get ClickHouse table column datatype.
Because this mapping is static

static constexpr auto string_max_size = 0xFFFFFF;

odbc setting StringMaxLength doesn't have any affect on it.

#define INI_STRINGMAXLENGTH "StringMaxLength"

Looks like it can manually fixed by applying this patch (if all your strings no longer than 4000 chars) and build clickhouse-odbc.

--- a/driver/utils/type_info.h
+++ b/driver/utils/type_info.h
@@ -24,7 +24,7 @@ struct TypeInfo {
     int32_t column_size;  // max width of value in textual represntation, e.g. number of decimal digits for numeric types.
     int32_t octet_length; // max binary size of value in memory.

-    static constexpr auto string_max_size = 0xFFFFFF;
+    static constexpr auto string_max_size = 0x000FA0;

     inline bool isIntegerType() const noexcept {
         return sql_type == SQL_TINYINT || sql_type == SQL_SMALLINT || sql_type == SQL_INTEGER || sql_type == SQL_BIGINT;
help xxxx
| TABLE_CAT | TABLE_SCHEM 	| TABLE_NAME    | COLUMN_NAME   | DATA_TYPE| TYPE_NAME    | COLUMN_SIZE| BUFFER_LENGTH| DECIMAL_DIGITS| NUM_PREC_RADIX| NULLABLE| REMARKS| COLUMN_DEF| SQL_DATA_TYPE| SQL_DATETIME_SUB| CHAR_OCTET_LENGTH| ORDINAL_POSITION| IS_NULLABLE|
| default  	|  				| xxxx      	| key        	| 12       | TEXT         | 4000       | 0            | 0             | 0             | 0       | 0      | 0         | 12           | 0               | 4000             | 0               | 0          |

But it will be very nice to be able to override it via settings.