-
Notifications
You must be signed in to change notification settings - Fork 624
Expand file tree
/
Copy pathDriverProperties.java
More file actions
187 lines (154 loc) · 6.9 KB
/
DriverProperties.java
File metadata and controls
187 lines (154 loc) · 6.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package com.clickhouse.jdbc;
import com.clickhouse.client.api.ClientConfigProperties;
import com.clickhouse.client.api.internal.ServerSettings;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
/**
* JDBC driver specific properties. Does not include anything from ClientConfigProperties.
* Processing logic should be the follows
* 1. If property is among DriverProperties then Driver handles it specially and will not pass to a client
* 2. If property is not among DriverProperties then it is passed to a client
*/
public enum DriverProperties {
/**
* Indicates if driver should ignore unsupported values and methods.
* JDBC allows throwing SQLException for unsupported values and methods.
* But driver can ignore them and continue execution. Driver will do no operation in such case.
*/
IGNORE_UNSUPPORTED_VALUES("jdbc_ignore_unsupported_values", String.valueOf(Boolean.FALSE)),
/**
* Schema term to be used in the connection URL. Only `schema` is supported right now.
*/
SCHEMA_TERM("jdbc_schema_term", "schema"),
/**
* Indicates if driver should create a secure connection over SSL/TLS
*/
SECURE_CONNECTION("ssl", String.valueOf(Boolean.FALSE)),
/**
* Query settings to be passed along with query operation.
* {@see com.clickhouse.client.api.query.QuerySettings}
*/
DEFAULT_QUERY_SETTINGS("default_query_settings", null),
/**
* Enables row binary writer for simple insert statements when
* PreparedStatement is used. Has limitation and can be used with a simple form of insert like;
* {@code INSERT INTO t VALUES (?, ?, ?...)}
*/
BETA_ROW_BINARY_WRITER("beta.row_binary_for_simple_insert", String.valueOf(Boolean.FALSE)),
/**
* Enables closing result set before
*/
RESULTSET_AUTO_CLOSE("jdbc_resultset_auto_close", String.valueOf(Boolean.TRUE)),
/**
* Enables using server property `max_result_rows` ({@link ServerSettings#MAX_RESULT_ROWS} to limit number of rows returned by query.
* Enabling this property will override user set overflow mode. It may cause error if server doesn't allow changing properties.
* When this property is not enabled then result set will stop reading data once limit is reached. As server may have
* more in a result set then it will require time to read all data to make HTTP connection usable again. In most cases
* this is fine. It is recommended to set limit in SQL query.
*
*/
USE_MAX_RESULT_ROWS("jdbc_use_max_result_rows", String.valueOf(Boolean.FALSE)),
/**
* Configures what SQL parser will be used. Choices:
* <ul>
* <li>ANTLR4 - parser extracts required information but PreparedStatement parameters parsed separately.</li>
* <li>ANTLR4_PARAMS_PARSER - parser extracts required information AND parameter positions.</li>
* <li>JAVACC - parser extracts required information but PreparedStatement parameters parsed separately.</li>
* </ul>
*/
SQL_PARSER("jdbc_sql_parser", "JAVACC", Arrays.asList("ANTLR4", "ANTLR4_PARAMS_PARSER", "JAVACC")),
/**
* Sets query ID generator as {@link java.util.function.Supplier<String>} to be used for Query ID generation
* before sending request with client.
* When no set - queryID is generated by using {@link UUID#randomUUID()}.
*/
QUERY_ID_GENERATOR("jdbc_query_id_generator", null),
/**
* Controls logic of saving roles that were set using {@code SET <role>} statement.
* Default: true - save roles
*/
REMEMBER_LAST_SET_ROLES("remember_last_set_roles", String.valueOf(Boolean.TRUE)),
/**
* Deprecated and will be removed.
* This property is here to keep backward compatibility with {@code com.clickhouse.client.http.config.ClickHouseHttpOption#CUSTOM_PARAMS}.
* Original property is deprecated for {@code com.clickhouse.client.config.ClickHouseClientOption#CUSTOM_SETTINGS}
* This property is expected to be a comma separated list of key-value pair that should be sent to server.
* Pairs will be converted to new properties for client config.
* Use {@link ClientConfigProperties#serverSetting(String)} instead
*
*/
@Deprecated
CUSTOM_HTTP_PARAMS("custom_http_params", null),
/**
* Deprecated and will be removed.
* This property is here to keep backward compatibility with {@code com.clickhouse.client.config.ClickHouseClientOption#CUSTOM_SETTINGS}.
* This property is expected to be a comma separated list of key-value pair that should be sent to server.
* Pairs will be converted to new properties for client config.
* Use {@link ClientConfigProperties#serverSetting(String)} instead
*
*/
@Deprecated
CUSTOM_SETTINGS("custom_settings", null),
/**
* Deprecated as driver do not convert Date values to any timezone. Dates are sent as is.
* Problem having this setting on connection level is that affects all child statements and
* there is no way to control on column basis.
* Driver ignores this setting but will throw exception when it is completely removed.
*/
@Deprecated
USE_TZ_FOR_DATES("use_server_time_zone_for_dates", null),
/**
* Current driver implementation uses only one http provider. So setting it has no effect.
* Deprecated will be removed soon
*/
@Deprecated
HTTP_CONNECTION_PROVIDER("http_connection_provider", null),
/**
* Define cluster name for statement executions like KILL
*/
CLUSTER_NAME("jdbc_cluster_name", null),
/**
* Define custom type mappings for JDBC ResultSet#getObject() method.
* Format of the property is 'key=value'.
* Key is the ClickHouse type name.
* Value is the Java class name.
* Example: 'UInt64=java.lang.String'
*/
JDBC_TYPE_MAPPINGS("jdbc_type_mappings", null),
/**
* Deprecated and will be removed.
* This property is here to keep backward compatibility with `typeMappings` property.
* Use `jdbc_type_mappings` instead
*/
@Deprecated
TYPE_MAPPINGS("typeMappings", null),
;
private final String key;
private final String defaultValue;
private final List<String> choices;
DriverProperties(String key, String defaultValue) {
this(key, defaultValue, Collections.emptyList());
}
DriverProperties(String key, String defaultValue, List<String> choices) {
this.key = key;
this.defaultValue = defaultValue;
this.choices = choices;
}
public String getKey() {
return key;
}
public String getDefaultValue() {
return defaultValue;
}
public List<String> getChoices() {
return choices;
}
public static String serverSetting(String key) {
return ClientConfigProperties.serverSetting(key);
}
public static String httpHeader(String key) {
return ClientConfigProperties.httpHeader(key);
}
}