Fields
Column(type='', name='', *, default_type='', default_expression='', comment='', codec_expression='', ttl_expression='')
dataclass
Represents a ClickHouse column. Can be manually constructed or created from a pydantic.Field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
str
|
The ClickHouse type of the column. |
''
|
name
|
str
|
The name of the column. |
''
|
default_type
|
str
|
The default type of the column. |
''
|
default_expression
|
str
|
The default expression of the column. |
''
|
comment
|
str
|
The comment of the column. |
''
|
codec_expression
|
str
|
The codec expression of the column. |
''
|
ttl_expression
|
str
|
The TTL expression of the column. |
''
|
Examples:
>>> Column(type="String", name="name")
Column(type='String', name='name', default_type='', default_expression='', comment='', codec_expression='', ttl_expression='')
from_field(name, info)
classmethod
Create a Column instance from a pydantic.Field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the column. |
required |
info
|
FieldInfo
|
|
required |
from_sql(**kwargs)
classmethod
Create a Column instance from a SQL column definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Column definition keyword arguments. |
{}
|
to_sql()
Convert the column to a SQL column definition.
Returns:
| Type | Description |
|---|---|
str
|
SQL column definition as a string. |
Expression(value)
ClickHouse Query expression with support for operations.
Accessing the columns on a table returns an Expression object.
Supports the following operations
- Arithmetic: +, -, *, /
- Comparison: <, <=, >, >=, ==, !=
- Logical: &&, ||
- Negation: !
- Unary: +, -
- Containment: in, not_in
Examples:
>>> Expression("column") + 1
column + 1
>>> Expression("column") > Expression("other)
column > other
>>> Expression("column").is_in([1, 2, 3])
column | in [1, 2, 3]
Function(name, *args)
Aggregate(value)
Param(name, type=str)
ClickHouse parameter used in queries for parameterized values.
Requires a type for the parameter, which is used by ClickHouse to infer the type of the parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the parameter. |
required |
type
|
type
|
ClickHouse type. Defaults to |
str
|
Examples:
Window(*, range=None, rows=None)
ClickHouse window specification used in window pipelines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
range
|
tuple[int | None, int | None] | None
|
tuple of (start, end) for range window. Start and end can be None, which represents unbounded. Cannot be specified with rows. |
None
|
rows
|
tuple[int | None, int | None] | None
|
tuple of (start, end) for rows window. Start and end can be None, which represents unbounded. Cannot be specified with range. |
None
|