-
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
Conversation
@@ -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"), |
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
EPHEMERAL("EPHEMERAL"), | ||
ALIAS("ALIAS"); | ||
|
||
public final String defaultValue; |
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.
May be lets rename it to kind
or type
just to avoid too many defaultValue
in one place?
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.
See my last comment, I prefer to stick with ClickHouse documentation language
|
This pull request introduces support for handling default values in ClickHouse columns, including
MATERIALIZED
,ALIAS
, andEPHEMERAL
types. It adds new functionality to skip these columns during data insertion and ensures proper parsing and testing of default expressions. The most important changes are grouped below:Enhancements to
ClickHouseColumn
class:DefaultValue
enum to represent different default types (DEFAULT
,MATERIALIZED
,EPHEMERAL
,ALIAS
) and associated fieldsdefaultValue
anddefaultExpression
to theClickHouseColumn
class.defaultValue
anddefaultExpression
in theClickHouseColumn
class.Changes to data insertion logic:
insert
method inClient.java
to skip columns with default values other thanDEFAULT
during data insertion.commitRow
method inRowBinaryFormatWriter.java
to similarly skip columns withMATERIALIZED
,ALIAS
, or other non-default values.Schema parsing improvements:
TableSchemaParser
to parsedefault_type
anddefault_expression
properties from table schema and set them inClickHouseColumn
.New test cases:
testWriterWithMaterialize
to validate insertion behavior with columns having various default types (MATERIALIZED
,ALIAS
,EPHEMERAL
).insertSimplePOJOsWithMaterializeColumn
test to verify POJO insertion withMATERIALIZED
andALIAS
columns.Additional utility class:
SimplePOJO
class with a method to generate table creation SQL for testing columns with default values and default expressions.## SummaryCloses #2118 #2025
Checklist
Delete items not relevant to your PR: