Documentation
¶
Overview ¶
Package clickhouse projects Invariant's canonical protobuf data schema into ClickHouse column and constraint declarations. It deliberately does not choose a table engine, sorting key, partitioning, or other physical policy.
Index ¶
Constants ¶
const ProjectionVersion = 2
ProjectionVersion is the version of the ClickHouse-to-Iceberg projection model. It is independent of SchemaBundle's canonical IR version.
Variables ¶
This section is empty.
Functions ¶
func ProjectionJSON ¶
func ProjectionJSON(projection *IcebergProjection) ([]byte, error)
ProjectionJSON returns a deterministic JSON representation of a conversion plan. Field order follows SchemaBundle order.
Types ¶
type Column ¶
type Column struct {
Name string
Type string
DefaultExpression string
Comment string
FieldPath string
StableID int32
Synthetic bool
}
Column is one top-level ClickHouse column declaration.
type Constraint ¶
Constraint is one ClickHouse CHECK constraint required by the logical schema. Callers must apply Constraints together with Columns.
type IcebergFieldProjection ¶
type IcebergFieldProjection struct {
FieldPath string `json:"field_path"`
Name string `json:"name"`
StableID int32 `json:"stable_id"`
ClickHouseType string `json:"clickhouse_type"`
IcebergType string `json:"iceberg_type"`
PresenceExpression string `json:"presence_expression"`
ValueExpression string `json:"value_expression"`
FixedLength uint32 `json:"fixed_length,omitempty"`
Discriminator string `json:"discriminator,omitempty"`
ProtobufFieldNumber uint32 `json:"protobuf_field_number,omitempty"`
Children []IcebergFieldProjection `json:"children,omitempty"`
}
IcebergFieldProjection is one node in a deterministic structural conversion plan. Expressions use {value} for the current physical value and {case} for a oneof's sibling discriminator. A publisher evaluates ValueExpression only when PresenceExpression is true, then recursively applies Children.
type IcebergProjection ¶
type IcebergProjection struct {
Version uint32 `json:"version"`
Dataset string `json:"dataset"`
SourceMessage string `json:"source_message"`
Fields []IcebergFieldProjection `json:"fields"`
}
IcebergProjection describes how a publisher reads ClickHouse values into the existing Iceberg-compatible representation. It is a conversion plan, not an ingestion runtime or a promise of ClickHouse catalog interoperability.
func ProjectToIceberg ¶
func ProjectToIceberg( dataset *datav1.DatasetSchema, ) (*IcebergProjection, []*datav1.MappingDiagnostic, error)
ProjectToIceberg returns a structural conversion plan from the native ClickHouse representation to the schema emitted by data/iceberg, together with diagnostics from both target mappings. In particular, UInt64 and fixed64 use accurateCast({value}, 'Decimal(20, 0)'); every UInt64 value is exactly representable by Iceberg decimal(20,0).
type TableSchema ¶
type TableSchema struct {
Dataset string
SourceMessage string
Description string
Columns []Column
Constraints []Constraint
}
TableSchema is the ClickHouse projection for one canonical dataset. ColumnDeclarations returns a table-body fragment; this type does not select a database, table engine, ORDER BY key, or any other physical layout.
func Schema ¶
func Schema(dataset *datav1.DatasetSchema) (*TableSchema, []*datav1.MappingDiagnostic, error)
Schema maps one canonical dataset to ClickHouse column declarations. Every logical field, including collection children, produces a diagnostic.
func (*TableSchema) ColumnDeclarations ¶
func (schema *TableSchema) ColumnDeclarations() string
ColumnDeclarations returns deterministic ClickHouse column and constraint declarations without surrounding parentheses or a CREATE TABLE statement.