housepower / ClickHouse-Native-JDBC

ClickHouse Native Protocol JDBC implementation
https://housepower.github.io/ClickHouse-Native-JDBC/
Apache License 2.0
527 stars 145 forks source link

Unknown data type: IPv6 #430

Closed Tiakon closed 1 year ago

Tiakon commented 1 year ago

Environment

Error logs

com.github.housepower.exception.ClickHouseSQLException: Unknown data type: IPv6

    at com.github.housepower.misc.ExceptionUtil.rethrowSQLException(ExceptionUtil.java:70)
    at com.github.housepower.jdbc.statement.ClickHousePreparedInsertStatement.initBlockIfPossible(ClickHousePreparedInsertStatement.java:207)
    at com.github.housepower.jdbc.statement.ClickHousePreparedInsertStatement.<init>(ClickHousePreparedInsertStatement.java:111)
    at com.github.housepower.jdbc.ClickHouseConnection.prepareStatement(ClickHouseConnection.java:170)
    at com.ngaa.bigdata.util.clickhouse.ClickHouseTcpJavaClientTest.batchInsertToPCdnDBHostDataLocal(ClickHouseTcpJavaClientTest.java:226)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.sql.SQLException: Unknown data type: IPv6
    at com.github.housepower.misc.Validate.isTrue(Validate.java:41)
    at com.github.housepower.data.DataTypeFactory.get(DataTypeFactory.java:104)
    at com.github.housepower.data.DataTypeFactory.get(DataTypeFactory.java:66)
    at com.github.housepower.data.Block.readFrom(Block.java:43)
    at com.github.housepower.protocol.DataResponse.readFrom(DataResponse.java:32)
    at com.github.housepower.protocol.Response.readFrom(Response.java:33)
    at com.github.housepower.client.NativeClient.receiveResponse(NativeClient.java:183)
    at com.github.housepower.client.NativeClient.receiveSampleBlock(NativeClient.java:106)
    at com.github.housepower.jdbc.ClickHouseConnection.getSampleBlock(ClickHouseConnection.java:275)
    at com.github.housepower.jdbc.statement.ClickHousePreparedInsertStatement.lambda$initBlockIfPossible$0(ClickHousePreparedInsertStatement.java:208)
    at com.github.housepower.misc.ExceptionUtil.rethrowSQLException(ExceptionUtil.java:64)
    ... 32 more

Steps to reproduce

sql CREATE TABLE hits (url String, from IPv6) ENGINE = MergeTree() ORDER BY url;

    pstmt.setString(2, "2a02:aa08:e000:3100::2");

An exception occurs when IPv6 data is inserted into the jdbc code because the field in the table is of ipv6 type.

Other descriptions

When the fields in my table are of type ipv6, I don't know which type to insert. Is it because the current ClickHouse Native JDBC does not support IPV6? If I use the wrong data type, please tell me which data type should be used, I will be very grateful.

tongle1 commented 1 year ago

现在的java版本客户端还没支持IPv6,C++的是支持的。