graflo.db.nebula.util¶
NebulaGraph utility functions.
Type mapping, filter rendering, value escaping, and schema-propagation helpers.
Attributes¶
DEFAULT_NEBULA_TYPE = 'string'
module-attribute
¶
FIELD_TYPE_TO_NEBULA = {FieldType.INT: 'int64', FieldType.UINT: 'int64', FieldType.FLOAT: 'float', FieldType.DOUBLE: 'double', FieldType.BOOL: 'bool', FieldType.STRING: 'string', FieldType.DATETIME: 'string', FieldType.UUID: 'string'}
module-attribute
¶
NEBULA_TYPE_TO_FIELD_TYPE = {'int': FieldType.INT, 'int8': FieldType.INT, 'int16': FieldType.INT, 'int32': FieldType.INT, 'int64': FieldType.INT, 'float': FieldType.FLOAT, 'double': FieldType.DOUBLE, 'bool': FieldType.BOOL, 'string': FieldType.STRING, 'date': FieldType.DATETIME, 'time': FieldType.DATETIME, 'datetime': FieldType.DATETIME, 'timestamp': FieldType.DATETIME}
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
Functions:¶
escape_nebula_string(value)
¶
field_type_from_nebula(declared)
¶
Map a DESCRIBE TAG / DESCRIBE EDGE type back to a FieldType.
Returns None for a type this mapping does not cover, so the caller can
leave the field untyped rather than assert a wrong one.
Source code in graflo/db/nebula/util.py
is_nebula_string_field(field)
¶
Whether field becomes a variable-length string column.
Index DDL must ask the same question the column DDL answered: Nebula
rejects CREATE TAG INDEX on a string column given without a length.
Testing field.type == FieldType.STRING is not that question — an
untyped field, a DATETIME and a UUID all land on string too,
and an index over any of them is rejected as Invalid param!.
Source code in graflo/db/nebula/util.py
make_vid(doc, match_keys)
¶
Derive a VID string from a document's match-key values.
When a single match key is used the raw value is taken. When multiple keys
are present the values are joined with :: so the VID is deterministic
and unique for the combination.
Source code in graflo/db/nebula/util.py
nebula_type(ft)
¶
Map a scalar graflo FieldType to the corresponding NebulaGraph type name.
LIST is not storable as a Nebula property — use :func:nebula_type_for_field.
Source code in graflo/db/nebula/util.py
nebula_type_for_field(field)
¶
Map a Field to a NebulaGraph DDL type, raising for unsupported types.
render_filters_cypher(filters, doc_name)
¶
Render a FilterExpression as a Cypher WHERE clause (without the keyword).
Source code in graflo/db/nebula/util.py
render_filters_ngql(filters, doc_name)
¶
Render a FilterExpression as an nGQL WHERE clause (without the keyword).
Source code in graflo/db/nebula/util.py
serialize_nebula_value(value)
¶
Serialise a Python value into an nGQL literal string.
Source code in graflo/db/nebula/util.py
wait_for_schema_propagation(adapter, check_statement, *, max_retries=30, interval=1.0)
¶
Poll check_statement until it succeeds or retries are exhausted.
NebulaGraph propagates schema changes asynchronously across the cluster.
After CREATE SPACE / CREATE TAG / CREATE EDGE, subsequent
statements may fail until propagation completes (typically within two
heartbeat cycles, ~20 s for default settings).
Source code in graflo/db/nebula/util.py
wait_for_space_ready(adapter, space_name, *, max_retries=30, interval=1.0)
¶
Wait until SE `space_name succeeds.