noc.core.clickhouse.fields

Module Contents

class noc.core.clickhouse.fields.BaseField(default=None, description=None, low_cardinality=False)

Bases: object

BaseField class for ClickHouse structure

FIELD_NUMBER
db_type
default_value =
set_name(self, name)

Set field name according to model

Parameters:name – Field name
Returns:
iter_create_sql(self)

Yields (field name, db type) for all nested fields

Returns:
get_db_type(self, name=None)

Return Field type. Use it in create query

Parameters:name – Optional nested field name
Returns:
get_displayed_type(self)

Return Field type for external application :return:

apply_json(self, row_json, value)

Append converted value to row _json dict

Parameters:
  • json – Row dict
  • value – Raw value
Returns:

to_json(self, value)

Convert value to JSON-serializeable format

Parameters:value – Input value
Returns:JSON-serializable value
to_python(self, value)

Use method when field convert to python object :param value: :return:

get_select_sql(self)
static nested_path(name)

Split nested path to field name and nested name

Parameters:name – Nested field name
Returns:(Field name, Nested name)
class noc.core.clickhouse.fields.StringField

Bases: noc.core.clickhouse.fields.BaseField

db_type = String
default_value =
class noc.core.clickhouse.fields.DateField

Bases: noc.core.clickhouse.fields.BaseField

db_type = Date
default_value = 0000-00-00
to_json(self, value)
to_python(self, value)
class noc.core.clickhouse.fields.DateTimeField

Bases: noc.core.clickhouse.fields.BaseField

db_type = DateTime
default_value = 0000-00-00 00:00:00
to_json(self, value)
to_python(self, value)
class noc.core.clickhouse.fields.UInt8Field

Bases: noc.core.clickhouse.fields.BaseField

db_type = UInt8
default_value = 0
to_json(self, value)
to_python(self, value)
class noc.core.clickhouse.fields.UInt16Field

Bases: noc.core.clickhouse.fields.UInt8Field

db_type = UInt16
class noc.core.clickhouse.fields.UInt32Field

Bases: noc.core.clickhouse.fields.UInt8Field

db_type = UInt32
class noc.core.clickhouse.fields.UInt64Field

Bases: noc.core.clickhouse.fields.UInt8Field

db_type = UInt64
class noc.core.clickhouse.fields.Int8Field

Bases: noc.core.clickhouse.fields.UInt8Field

db_type = Int8
class noc.core.clickhouse.fields.Int16Field

Bases: noc.core.clickhouse.fields.UInt8Field

db_type = Int16
class noc.core.clickhouse.fields.Int32Field

Bases: noc.core.clickhouse.fields.UInt8Field

db_type = Int32
class noc.core.clickhouse.fields.Int64Field

Bases: noc.core.clickhouse.fields.UInt8Field

db_type = Int64
class noc.core.clickhouse.fields.Float32Field

Bases: noc.core.clickhouse.fields.BaseField

db_type = Float32
default_value = 0.0
to_json(self, value)
to_python(self, value)
class noc.core.clickhouse.fields.Float64Field

Bases: noc.core.clickhouse.fields.Float32Field

db_type = Float64
class noc.core.clickhouse.fields.BooleanField

Bases: noc.core.clickhouse.fields.UInt8Field

to_json(self, value)
to_python(self, value)
class noc.core.clickhouse.fields.ArrayField(field_type, description=None)

Bases: noc.core.clickhouse.fields.BaseField

to_json(self, value)
get_db_type(self, name=None)
get_displayed_type(self)
to_python(self, value)
class noc.core.clickhouse.fields.ReferenceField(dict_type, description=None, model=None, low_cardinality=False)

Bases: noc.core.clickhouse.fields.BaseField

db_type = UInt64
default_value = 0
SELF_REFERENCE = self
to_json(self, value)
class noc.core.clickhouse.fields.IPv4Field

Bases: noc.core.clickhouse.fields.BaseField

db_type = UInt32
to_json(self, value)

Convert IPv4 as integer

Parameters:value
Returns:
to_python(self, value)
get_displayed_type(self)
class noc.core.clickhouse.fields.AggregatedField(field_type, agg_functions, description=None, f_expr='')

Bases: noc.core.clickhouse.fields.BaseField

db_type
to_json(self, value)
get_create_sql(self)
get_expr(self, function, f_param)
class noc.core.clickhouse.fields.NestedField

Bases: noc.core.clickhouse.fields.ArrayField

db_type = Nested
iter_create_sql(self)
apply_json(self, row_json, value)
get_db_type(self, name=None)
get_displayed_type(self)
to_python(self, value)
get_select_sql(self)