clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

Select before insert with condition 'where 0'

Open dearestman opened this issue 1 year ago • 2 comments

When inserting into a table via executeBatch, before insert, Select is raised (which apparently checks for the presence of the required columns in the table) with Where 0. Is it possible to somehow disable this check? We are using 0.3.2-patch11 version with hikari pool

dearestman avatar Jan 15 '24 07:01 dearestman

Can you provide a snippet? Did you tried to use the latest version?

mzitnik avatar Jan 16 '24 06:01 mzitnik

same problem on latest version. My code:

public static void main(String[] args) {

        HikariConfig config = new HikariConfig();
        config.setJdbcUrl("jdbc:clickhouse://tkles-mess00065.vm.esrt.cloud.sbrf.ru:8123");
        config.setUsername("user");
        config.setPassword("password");

        HikariDataSource ds = new HikariDataSource(config);;

        try {

            Connection connection = ds.getConnection();

            String sql = "INSERT INTO sbol.test_jdbc_shard (name, surname) VALUES (?, ?)";

            PreparedStatement statement = connection.prepareStatement(sql);

            statement.setString(1, "test");
            statement.setString(2, "test2");

            statement.executeUpdate();

            System.out.println("Records were inserted successfully!");

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

there are 2 queries in log: SELECT name, surname FROM sbol.test_jdbc_shard WHERE 0 and INSERT INTO sbol.test_jdbc_shard (name, surname) VALUES ('test', 'test2') FORMAT RowBinary

maven dependencies:

 <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
      <groupId>com.clickhouse</groupId>
      <artifactId>clickhouse-jdbc</artifactId>
      <version>0.3.2-patch11</version>
      <exclusions>
        <exclusion>
          <groupId>com.clickhouse</groupId>
          <artifactId>clickhouse-grpc-client</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

dearestman avatar Jan 17 '24 09:01 dearestman