Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,110 @@
* doubt, just omit any specific format and let the driver take care of it.
* <p>
*
* @see <a href="https://clickhouse.yandex/docs/en/interfaces/formats">ClickHouse Reference Documentation</a>
* @see <a href=
* "https://clickhouse.yandex/docs/en/interfaces/formats">ClickHouse
* Reference Documentation</a>
*
* @author Dmitry Andreev <a href="mailto:[email protected]"></a>
*/
public enum ClickHouseFormat {
CustomSeparated,
TabSeparated,
TabSeparatedRaw,
TabSeparatedWithNames,
TabSeparatedWithNamesAndTypes,
CSV,
CSVWithNames,
Values,
Vertical,
JSON,
JSONCompact,
JSONCompactString,
JSONEachRow,
JSONStringEachRow,
JSONCompactEachRow,
JSONCompactStringEachRow,
TSKV,
TSV,
Pretty,
PrettyCompact,
PrettyCompactMonoBlock,
PrettyNoEscapes,
PrettySpace,
Protobuf,
RowBinary,
RowBinaryWithNamesAndTypes,
Native,
Null,
XML,
CapnProto,
Parquet,
ORC
;
Arrow(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#arrow
ArrowStream(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#arrowstream
Avro(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#avro
AvroConfluent(true, false, true, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#avroconfluent
CapnProto(true, false, true, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#capnproto
CSV(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#csv
CSVWithNames(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#csvwithnames
CustomSeparated(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#customseparated
JSON(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#json
JSONAsString(true, false, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#jsonasstring
JSONCompact(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompact
JSONCompactEachRow(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompacteachrow
JSONCompactEachRowWithNamesAndTypes(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompacteachrowwithnamesandtypes
JSONCompactString(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompactstring
JSONCompactStringEachRow(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompactstringeachrow
JSONCompactStringEachRowWithNamesAndTypes(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoncompactstringeachrowwithnamesandtypes
JSONEachRow(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoneachrow
JSONEachRowWithProgress(false, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsoneachrowwithprogress
JSONString(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#jsonstring
JSONStringsEachRow(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsonstringseachrow
JSONStringsEachRowWithProgress(false, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#jsonstringseachrowwithprogress
LineAsString(true, false, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#lineasstring
Native(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#native
Null(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#null
ORC(true, false, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#orc
Parquet(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#parquet
Pretty(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#pretty
PrettyCompact(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#prettycompact
PrettyCompactMonoBlock(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#prettycompactmonoblock
PrettyNoEscapes(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#prettynoescapes
PrettySpace(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#prettyspace
Protobuf(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#protobuf
ProtobufSingle(true, true, true, true, false), // https://clickhouse.tech/docs/en/interfaces/formats/#protobufsingle
RawBLOB(true, true, true, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#rawblob
Regexp(true, false, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#regexp
RowBinary(true, true, true, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#rowbinary
RowBinaryWithNamesAndTypes(true, true, true, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#rowbinarywithnamesandtypes
TabSeparated(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#tabseparated
TabSeparatedRaw(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#tabseparatedraw
TabSeparatedWithNames(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#tabseparatedwithnames
TabSeparatedWithNamesAndTypes(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#tabseparatedwithnamesandtypes
TSV(true, true, false, false, true), // alias of TabSeparated
TSVRaw(true, true, false, false, true), // alias of TabSeparatedRaw
TSVWithNames(true, true, false, true, true), // alias of TabSeparatedWithNames
TSVWithNamesAndTypes(true, true, false, true, true), // alias of TabSeparatedWithNamesAndTypes
Template(true, true, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#template
TemplateIgnoreSpaces(true, false, false, true, true), // https://clickhouse.tech/docs/en/interfaces/formats/#templateignorespaces
TSKV(true, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#tskv
Values(true, true, false, false, true), // https://clickhouse.tech/docs/en/interfaces/formats/#values
Vertical(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#vertical
VerticalRaw(false, true, false, false, false), // https://clickhouse.tech/docs/en/interfaces/formats/#verticalraw
XML(false, true, false, false, false); // https://clickhouse.tech/docs/en/interfaces/formats/#xml

private boolean input;
private boolean output;
private boolean binary;
private boolean header;
private boolean rowBased;

ClickHouseFormat(boolean input, boolean output, boolean binary, boolean header, boolean rowBased) {
this.input = input;
this.output = output;
this.binary = binary;
this.header = output && header;
this.rowBased = rowBased;
}

public boolean supportsInput() {
return input;
}

public boolean supportsOutput() {
return output;
}

public boolean isBinary() {
return binary;
}

public boolean isText() {
return !binary;
}

public boolean hasHeader() {
return header;
}

/**
* Check whether the format is row based(e.g. read/write by row), which is a
* very useful hint on how to process the data.
*
* @return true if the format is row based; false otherwise(e.g. column,
* document, or structured-object etc.)
*/
public boolean isRowBased() {
return rowBased;
}

public static boolean containsFormat(String statement) {
if (statement == null || statement.isEmpty()) {
Expand All @@ -60,5 +126,4 @@ public static boolean containsFormat(String statement) {
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public enum ClickHouseQueryParam implements DriverPropertyCreator {

FORCE_INDEX_BY_DATE("force_index_by_date", false, Boolean.class, ""),

FORCE_OPTIMIZE_SKIP_UNUSED_SHARDS("force_optimize_skip_unused_shards", 0, Integer.class, "Enables or disables query execution if optimize_skip_unused_shards is enabled and skipping of unused shards is not possible. If the skipping is not possible and the setting is enabled, an exception will be thrown."),

FORCE_PRIMARY_KEY("force_primary_key", false, Boolean.class, ""),

GLOBAL_SUBQUERIES_METHOD("global_subqueries_method", null, String.class, ""),
Expand Down Expand Up @@ -181,6 +183,8 @@ public enum ClickHouseQueryParam implements DriverPropertyCreator {

OPTIMIZE_MOVE_TO_PREWHERE("optimize_move_to_prewhere", true, Boolean.class, ""),

OPTIMIZE_SKIP_UNUSED_SHARDS("optimize_skip_unused_shards", 0, Integer.class, "Enables or disables skipping of unused shards for SELECT queries that have sharding key condition in WHERE/PREWHERE (assuming that the data is distributed by sharding key, otherwise does nothing)."),

OUTPUT_FORMAT_JSON_QUOTE_64BIT_INTEGERS("output_format_json_quote_64bit_integers", true, Boolean.class, "Controls quoting of 64-bit integers in JSON output format."),

OUTPUT_FORMAT_PRETTY_MAX_ROWS("output_format_pretty_max_rows", null, Long.class, "Rows limit for Pretty formats."),
Expand Down

This file was deleted.