-
Notifications
You must be signed in to change notification settings - Fork 586
Issue 2118 #2320
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
Issue 2118 #2320
Changes from all commits
68981c4
84803ff
4be93d0
3a2904c
9484a42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,21 @@ public final class ClickHouseColumn implements Serializable { | |
private Map<Class<?>, Integer> mapKeyToVariantOrdNumMap; | ||
private Map<Class<?>, Integer> mapValueToVariantOrdNumMap; | ||
|
||
public enum DefaultValue { | ||
DEFAULT("Default"), | ||
MATERIALIZED("MATERIALIZED"), | ||
EPHEMERAL("EPHEMERAL"), | ||
ALIAS("ALIAS"); | ||
|
||
public final String defaultValue; | ||
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. May be lets rename it to 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. See my last comment, I prefer to stick with ClickHouse documentation language |
||
|
||
DefaultValue(String defaultValue) { | ||
this.defaultValue = defaultValue; | ||
} | ||
} | ||
|
||
private DefaultValue defaultValue; | ||
private String defaultExpression; | ||
|
||
private static ClickHouseColumn update(ClickHouseColumn column) { | ||
column.enumConstants = ClickHouseEnum.EMPTY; | ||
|
@@ -853,6 +868,14 @@ public void setHasDefault(boolean hasDefault) { | |
this.hasDefault = hasDefault; | ||
} | ||
|
||
public void setDefaultValue(DefaultValue defaultValue) { this.defaultValue = defaultValue; } | ||
|
||
public DefaultValue getDefaultValue() { return defaultValue; } | ||
|
||
public void setDefaultExpression(String defaultExpression) { this.defaultExpression = defaultExpression; } | ||
|
||
public String getDefaultExpression() { return defaultExpression; } | ||
|
||
public boolean isLowCardinality() { | ||
return !lowCardinalityDisabled && lowCardinality; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.clickhouse.client.insert; | ||
|
||
import com.clickhouse.client.ClientTests; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.commons.lang3.RandomStringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Random; | ||
|
||
@Getter | ||
@Setter | ||
public class SimplePOJO { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(SimplePOJO.class); | ||
private int int32; | ||
private String str; | ||
private String hexed; | ||
|
||
public SimplePOJO() { | ||
long seed = System.currentTimeMillis(); | ||
final Random random = new Random(seed); | ||
this.int32 = random.nextInt(); | ||
this.str = RandomStringUtils.randomAlphabetic(1, 256); | ||
this.hexed = RandomStringUtils.randomAlphanumeric(4); | ||
} | ||
|
||
public static String generateTableCreateSQL(String tableName) { | ||
return "CREATE TABLE " + tableName + " (" + | ||
"int32 Int32, " + | ||
"str String, " + | ||
"int64 Int64 MATERIALIZED abs(toInt64(int32)), " + | ||
"str_lower String ALIAS lower(str), " + | ||
"unhexed String EPHEMERAL, " + | ||
"hexed FixedString(4) DEFAULT unhex(unhexed), " + | ||
") ENGINE = MergeTree ORDER BY ()"; | ||
} | ||
|
||
} | ||
|
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.
Should it be like Default - "Materialized" ?
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.
According to https://clickhouse.com/docs/sql-reference/statements/create/table#default_values all are
DefaultValue