-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing csv file into table #1001
Comments
How to import large CSV files quickly, What is a good implementation method, thanks |
Sorry for the late reply. // one-liner
ClickHouseClient.load(
ClickHouseNode.of("http://localhost:8123/system"),
"table_a",
// will parse file name later so that you don't have to specify compression and format
ClickHouseFile.of("/Users/zhicwu/a.csv.gz", ClickHouseCompression.GZIP, 0, ClickHouseFormat.CSV)).get();
// JDBC
Statement stmt = conn.createStatement();
stmt.unwrap(ClickHouseRequest).write().data(ClickHouseFile.of(...)).table("mytable").executeAndWait(); |
Very good!thanks!! Can GZ files be automatically compressed? For example, the CSV source files I import are automatically compressed by the interface |
@kiwimg, since patch11 has been released, you may refer to this for direct file loading, which should be similar to use curl. If you want Java client to take care of compression when uploading file, you just need to set input stream and compression algorithm in ClickHouseRequest. I'm still thinking a more consistent way of doing this so I changed milestone to 0.3.3. |
Thank you very much. You're really great |
what's difference between the so called "direct file loading" with the java client ClickhouseClient#load(ClickHouseNode server, String table, ClickHouseFormat format, ClickHouseCompression compression, String file) method @zhicwu |
The API was enhanced for scheme inferring although it's limited to a few file extensions. For example, passing file name @chigend, sorry for the late reply. To help you understand, let's start with an example. Assume you want to load |
thank you @zhicwu |
How to import CSV files into a table?
v0.3.2-patch10,use “ com.clickhouse.jdbc.ClickHouseStatement” Is this correct?
clickHouseStatement.write() // Write API entrypoint
.table(endPiont).format(ClickHouseFormat.CSV)// where to write data
.data(file.getAbsolutePath(), ClickHouseCompression.ZIP)/// specify input
.send();
ru.yandex.clickhouse.* will Deprecated
Before 0.3.2...
import ru.yandex.clickhouse.ClickHouseStatement;
ClickHouseStatement sth = connection.createStatement();
sth
.write() // Write API entrypoint
.table("default.my_table") // where to write data
.option("format_csv_delimiter", ";") // specific param
.data(new File("/path/to/file.csv.gz"), ClickHouseFormat.CSV, ClickHouseCompression.gzip) // specify input
.send();
The text was updated successfully, but these errors were encountered: