-
Notifications
You must be signed in to change notification settings - Fork 614
[client-v2] Support Variant, Dynamic, JSON Data Types #2130
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
Changes from all commits
f0645b1
96102c9
dc82be7
4f8de9d
2ae4d27
f18ce46
af28fca
d2b6d59
9c3a6ed
beae9f4
35f0b31
c6335d7
629c0be
dbee722
455b367
de27d86
48a0b09
e969608
7741b2f
170674e
b93815a
1b81ce5
eb68c76
775d36d
296d676
17b8770
edc87a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ protected ClickHouseEnum(Collection<String> params) { | |
| } | ||
| } | ||
|
|
||
| protected ClickHouseEnum(String[] names, int[] values) { | ||
| public ClickHouseEnum(String[] names, int[] values) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will it be more efficient to use a map here i see a lot scan operations that we have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Current approach is more memory efficient. We can introduce map and measure performance. |
||
| if (names == null || values == null) { | ||
| throw new IllegalArgumentException("Non-null names and values are required"); | ||
| } else if (names.length != values.length) { | ||
|
|
@@ -93,6 +93,16 @@ public String name(int value) { | |
| throw new IllegalArgumentException("Unknown enum value: " + value); | ||
| } | ||
|
|
||
| public String nameNullable(int value) { | ||
| for (int i = 0; i < size; i++) { | ||
| if (values[i] == value) { | ||
| return names[i]; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| public int value(String name) { | ||
| for (int i = 0; i < size; i++) { | ||
| if (names[i].equals(name)) { | ||
|
|
@@ -135,4 +145,16 @@ public String toSqlException() { | |
| } | ||
| return builder.toString(); | ||
| } | ||
|
|
||
| public int size() { | ||
| return size; | ||
| } | ||
|
|
||
| public String[] getNames() { | ||
| return names; | ||
| } | ||
|
|
||
| public int[] getValues() { | ||
| return values; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,6 +207,8 @@ public static boolean writeValuePreamble(OutputStream out, boolean defaultsSuppo | |
| return false;//And we're done | ||
| } else if (dataType == ClickHouseDataType.Array) {//If the column is an array | ||
| SerializerUtils.writeNonNull(out);//Then we send nonNull | ||
| } else if (dataType == ClickHouseDataType.Dynamic) { | ||
| // do nothing | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we can add an explanation why we are not doing here anything |
||
| } else { | ||
| throw new IllegalArgumentException(String.format("An attempt to write null into not nullable column '%s'", column)); | ||
| } | ||
|
|
@@ -221,6 +223,8 @@ public static boolean writeValuePreamble(OutputStream out, boolean defaultsSuppo | |
| } else if (value == null) { | ||
| if (dataType == ClickHouseDataType.Array) { | ||
| SerializerUtils.writeNonNull(out); | ||
| } else if (dataType == ClickHouseDataType.Dynamic) { | ||
| // do nothing | ||
| } else { | ||
| throw new IllegalArgumentException(String.format("An attempt to write null into not nullable column '%s'", column)); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to protect the constructor of such simple class.