ClickHouse / clickhouse-odbc

ODBC driver for ClickHouse
https://clickhouse.tech
Apache License 2.0
245 stars 86 forks source link

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

Open UnamedRus opened 2 years ago

UnamedRus commented 2 years ago

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 https://github.com/ClickHouse/clickhouse-odbc/blob/35394e53319a60d4ae9404117059813d76d28bd7/driver/utils/type_info.h#L27

odbc setting StringMaxLength doesn't have any affect on it. https://github.com/ClickHouse/clickhouse-odbc/blob/35394e53319a60d4ae9404117059813d76d28bd7/driver/config/ini_defines.h#L31

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.