You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
clickhouse-client -q "select number A, now() B, 'x' C from numbers(1e6) format Parquet" > test.parquet
clickhouse-client -q "select number A, now() B, 'x' C from numbers(1e6) format CSV" > test.csv
client.connect(server).write()
.query("insert into test ")
.format(ClickHouseFormat.Parquet)
.data("~/test.parquet")
.execute()
.get();
SEVERE: Failedtocreatestreamresponse, closinginputstreamExceptioninthread"main"com.clickhouse.client.ClickHouseException: Unsupportedformat: Parquet, serverClickHouseNode(addr=http:localhost/<unresolved>:8123, db=default)@84425729atcom.clickhouse.client.ClickHouseException.of(ClickHouseException.java:113)
atMain.main(Main.java:54)
the same works with CSV
client.connect(server).write()
.query("insert into test ")
.format(ClickHouseFormat.CSV)
.data("~/test.csv")
.execute()
.get();
Also WHY I cannot do insert into test format CSV ?
client.connect(server).write()
.query("insert into test format CSV")
.data("~/test.csv")
.execute()
.get();
Exception in thread "main" com.clickhouse.client.ClickHouseException: Code: 27. DB::ParsingException: Cannot parse input: expected ',' before: 'FORMAT TabSeparated\n0,"2022-04-28 20:56:27","x"\n1,"2022-04-28 20:56:27","x"\n2,"2022-04-28 20:56:27","x"\n3,"2022-04-28 20:56:27","x"\n4,"2022-04-28 20:56:27","x"\n':
Row 1:
Column 0, name: A, type: Int64, ERROR: text "FORMAT Tab" is not like Int64
: While executing CSVRowInputFormat: (at row 1)
. (CANNOT_PARSE_INPUT_ASSERTION_FAILED) (version 22.3.2.1)
, server ClickHouseNode(addr=http:localhost/<unresolved>:8123, db=default)@-1212239676
full code
importjava.io.*;
importjava.nio.charset.StandardCharsets;
importjava.sql.*;
importjava.util.Properties;
importjava.util.UUID;
importjava.util.concurrent.CompletableFuture;
importjava.util.concurrent.ExecutionException;
importcom.clickhouse.client.*;
importcom.clickhouse.client.config.ClickHouseClientOption;
importcom.clickhouse.client.data.BinaryStreamUtils;
importcom.clickhouse.client.data.ClickHouseExternalTable;
importcom.clickhouse.client.data.ClickHousePipedStream;
publicclassMain {
// clickhouse-client -q "select number A, now() B, 'x' C from numbers(1e6) format Parquet" > test.parquetpublicstaticvoidmain(String[] args) throwsClickHouseException {
finalStringDB_HOST = "localhost";
finalStringUSER = "default";
finalStringPASS = "";
ClickHouseNodeserver = ClickHouseNode.builder()
.host("localhost")
.port(ClickHouseProtocol.HTTP, 8123)
.database("default")
.credentials(ClickHouseCredentials.fromUserAndPassword(USER,PASS))
.build();
try (ClickHouseClientclient = ClickHouseClient.newInstance(server.getProtocol())) {
ClickHouseRequest<?> request = client.connect(server);
request.query("drop table if exists test").execute().get();
request.query("create table test(A Int64, B DateTime, C String) engine=MergeTree() order by A").execute().get();
client.connect(server).write()
.query("insert into test")
.format(ClickHouseFormat.Parquet)
.data("~/test.parquet")
.execute()
.get();
ClickHouseResponseresponse = request.query("select count() from test").execute().get();
for (ClickHouseRecordrec : response.records()) {
System.out.println(rec.getValue(0).asString());
}
} catch (InterruptedExceptione) {
Thread.currentThread().interrupt();
throwClickHouseException.forCancellation(e, server);
} catch (ExecutionExceptione) {
throwClickHouseException.of(e, server);
}
}
The text was updated successfully, but these errors were encountered:
Thanks @den-crane. Yes we should be able to load data into a table as long as the format is supported by ClickHouse.
Java client does not parse query which is one of the reasons why it's faster than JDBC driver. However, insert into test format CSV(with data specified) could be a simple case(unlike select query which may have settings after format clause) that we can support.
the same works with CSV
Also WHY I cannot do
insert into test format CSV
?full code
The text was updated successfully, but these errors were encountered: