ClickHouse/clickhouse-jdbc-bridge

insert into is broken (At least one column is needed)

mikeTWC1984 opened this issue · 4 comments

I'm using CH 21.9.3.30 and the latest jdbc bridge (using container, I guess it's 2.0.4). I was able to set up jdbc table and then select from it, but insert throws At least one column is needed.

-- docker run -e "ACCEPT_EULA=Y" -e 'SA_PASSWORD=myPass' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest

create table jdbc_test (a Int32, b Int32)
ENGINE=JDBC('jdbc:sqlserver://172.17.0.4;databaseName=test;username=sa;password=myPass', 'dbo', 'test')

 -- select works as expected
select * from jdbc_test

-- insert throwing  "At least one column is needed" error
insert into jdbc_test(a, b)
select 2, 4

Sorry it's a bug and I'll fix it tonight in 2.0.5.

Fixed in 2.0.5. Upgrade and restart jdbc bridge and then you should be able to insert data into jdbc table.

Thanks for quick turnaround. I see insert is working now, however it's extremely slow. I guess it's using default 100 row batch size. I'm trying to set batch size using below method but it doesn't change anything (it's inserting ~200 rows per second). Is that the right way to set batch size?

CREATE TABLE jtest2
(
    `a` Int32,
    `b` Int32
)
ENGINE = JDBC('mysql8?batch_size=10000', '', 'test')

insert into jtest (a, b) select number*3, number*5 from system.numbers limit 15000;

Yes, increasing batch_size helps in general. If the target database is MySQL, besides using official JDBC driver(instead of MariaDB Java client), you'd better enable rewriteBatchedStatements as well.