graflo.architecture.schema.database_features¶
Database-specific schema features.
This module stores physical DB features that are separate from logical graph identity.
Attributes¶
Classes¶
DatabaseProfile
¶
Bases: ConfigBaseModel
Container for DB-only physical features such as secondary indexes.
Source code in graflo/architecture/schema/database_features.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | |
Attributes¶
db_flavor = PydanticField(default=DBType.ARANGO, description='Target DB flavor used for physical naming and defaults.')
class-attribute
instance-attribute
¶
default_property_values = PydanticField(default=None, description='Optional per-attribute GSQL DEFAULT values for TigerGraph (and similar) DDL. Vertex keys are logical vertex names; edge entries match logical (source, target, relation). Does not change logical LPG types—only physical schema projection.')
class-attribute
instance-attribute
¶
edge_specs = PydanticField(default_factory=list, description='Unified edge physical specs keyed by edge identity + purpose.')
class-attribute
instance-attribute
¶
native_inverses = PydanticField(default_factory=list, description='TigerGraph only: relations whose declared inverse the database maintains as a paired type (GSQL ``WITH REVERSE_EDGE``). Keyed by relation because TigerGraph sets the reverse type on the edge type, which spans every (source, target) pair of the relation. The paired type is named by ``edge_config.inverses``, never here. Mutually exclusive with explicit inverse edges.')
class-attribute
instance-attribute
¶
target_namespace = PydanticField(default=None, description='Runtime target LPG namespace when the connection config leaves it unset: Arango/Neo4j/FalkorDB/Memgraph database, TigerGraph graph name, Nebula space. Validated against the flavor, never rewritten. When unset, the namespace is schema.metadata.name sanitized per flavor (Schema.effective_namespace).')
class-attribute
instance-attribute
¶
vertex_indexes = PydanticField(default_factory=dict, description='Secondary indexes per vertex name (identity excluded).')
class-attribute
instance-attribute
¶
vertex_storage_names = PydanticField(default_factory=dict, description='Physical vertex collection/label names keyed by logical vertex name.')
class-attribute
instance-attribute
¶
Methods:¶
add_edge_index(edge_id, index, *, purpose=None)
¶
Source code in graflo/architecture/schema/database_features.py
add_vertex_index(vertex_name, index)
¶
Register a secondary index for vertex_name if not already present.
Idempotent on the field-set, so repeated schema resolution does not
accumulate duplicates -- deliberately weaker than :func:append_index.
The caller here is a generator (compile_secondary_identity_indexes
derives a lookup index from a declared secondary identity), so an
authored unique index over the same fields is not a competing claim to
refuse but the stronger one to leave alone. Two authored profiles
meeting is the case that refuses, and that goes through
:func:append_index.
Source code in graflo/architecture/schema/database_features.py
edge_graph_name(edge_id, *, source_storage, target_storage, purpose=None)
¶
Source code in graflo/architecture/schema/database_features.py
edge_index_spec(edge_id, purpose=None)
¶
Source code in graflo/architecture/schema/database_features.py
edge_name_spec(edge_id, purpose=None)
¶
Source code in graflo/architecture/schema/database_features.py
edge_physical_variants(edge_id, *, source_storage, target_storage)
¶
Return resolved physical variants (base + purpose copies) for one edge.
Source code in graflo/architecture/schema/database_features.py
edge_property_default(edge_id, property_name)
¶
Return declared default for an edge attribute, or None if not specified.
Source code in graflo/architecture/schema/database_features.py
edge_purposes(edge_id)
¶
Return declared physical purposes for an edge.
The base variant (None) is always included; additional purposes are
collected from matching edge variant specs.
Source code in graflo/architecture/schema/database_features.py
edge_relation_name(edge_id, default_relation=None, purpose=None)
¶
Source code in graflo/architecture/schema/database_features.py
edge_secondary_indexes(edge_id, purpose=None)
¶
Source code in graflo/architecture/schema/database_features.py
edge_storage_name(edge_id, *, source_storage, target_storage, purpose=None)
¶
Source code in graflo/architecture/schema/database_features.py
has_edge_index_spec(edge_id, *, purpose=None)
¶
Return True when an exact purpose edge index spec exists.
Source code in graflo/architecture/schema/database_features.py
has_edge_property_default(edge_id, property_name)
¶
Source code in graflo/architecture/schema/database_features.py
has_explicit_edge_indexes(edge_id, *, purpose=None)
¶
Source code in graflo/architecture/schema/database_features.py
has_native_inverse(relation)
¶
Whether the database maintains the declared inverse of relation.
has_vertex_property_default(vertex_name, property_name)
¶
Source code in graflo/architecture/schema/database_features.py
native_inverse_of(relation, edge_config)
¶
Name of the database-maintained reverse type of relation, if any.
The name is the declared inverse (edge_config.inverses); the profile
only says that the database, rather than explicit edges, realizes it.
Source code in graflo/architecture/schema/database_features.py
prune_empty_vertex_indexes()
¶
Drop vertex entries whose index list is empty.
An empty list and an absent key describe the same profile, but they serialize — and therefore hash — differently. Since content hashes are what verify a replayed manifest against an authored one, leaving the empty entry behind would make identical schemas compare unequal.
Source code in graflo/architecture/schema/database_features.py
set_edge_name_spec(edge_id, *, relation_name=None, purpose=None)
¶
Source code in graflo/architecture/schema/database_features.py
validate_against_schema(edge_config)
¶
Assert all edge specs reference declared logical edges.
Source code in graflo/architecture/schema/database_features.py
validate_native_inverses(edge_config, vertex_names)
¶
Check every native inverse against the declared inverses and edges.
A native inverse is the database realizing a declared pair for a whole
relation, so it needs the declaration, must not coexist with explicit
inverse edges, and exists only where the database can maintain one: on a
single TigerGraph edge type whose reverse name is free. The rules
themselves are
:func:graflo.architecture.schema.inverse_realization.native_inverse_violations,
which also answers "would this relation be eligible?" without changing
the profile.
Raises:
| Type | Description |
|---|---|
ValueError
|
naming every rule broken and the relation that breaks it. |
Source code in graflo/architecture/schema/database_features.py
vertex_property_default(vertex_name, property_name)
¶
Return declared default for a vertex property, or None if not specified.
Source code in graflo/architecture/schema/database_features.py
vertex_secondary_indexes(vertex_name)
¶
DefaultPropertyValues
¶
Bases: ConfigBaseModel
TigerGraph-style attribute defaults for physical schema DDL (covariant profile).
Maps to GSQL attribute_name type [DEFAULT default_value] on vertices and edges;
see TigerGraph Defining a Graph Schema_.
.. _Defining a Graph Schema: https://docs.tigergraph.com/gsql-ref/4.2/ddl-and-loading/defining-a-graph-schema
Source code in graflo/architecture/schema/database_features.py
Attributes¶
edges = PydanticField(default_factory=list, description='Per (source, target, relation) edge type: attribute defaults.')
class-attribute
instance-attribute
¶
vertices = PydanticField(default_factory=dict, description='Logical vertex name -> property name -> default value for GSQL DEFAULT.')
class-attribute
instance-attribute
¶
EdgePhysicalSpec
¶
Bases: EdgeRef
Unified edge physical spec keyed by edge identity + purpose.
Source code in graflo/architecture/schema/database_features.py
Attributes¶
indexes = PydanticField(default_factory=list, description='Secondary indexes for this variant (or overrides based on indexes_mode).')
class-attribute
instance-attribute
¶
indexes_mode = PydanticField(default='inherit', description='How variant indexes relate to base (purpose=None): inherit=base only, append=base+variant, replace=variant only.')
class-attribute
instance-attribute
¶
physical_key
property
¶
purpose = PydanticField(default=None, description='DB-only purpose identifier for physical edge variant.')
class-attribute
instance-attribute
¶
relation_name = PydanticField(default=None, description='Database-specific relation/type name override for the variant.')
class-attribute
instance-attribute
¶
EdgePropertyDefaults
¶
Bases: EdgeRef
Per logical edge type: optional GSQL DEFAULT values for edge attributes.
Source code in graflo/architecture/schema/database_features.py
EdgeRef
¶
Bases: ConfigBaseModel
Reference to a logical edge identity.
Source code in graflo/architecture/schema/database_features.py
Attributes¶
edge_id
property
¶
relation = PydanticField(default=None, description='Logical relation for edge identity (source, target, relation).')
class-attribute
instance-attribute
¶
source = PydanticField(..., description='Edge source vertex name.')
class-attribute
instance-attribute
¶
target = PydanticField(..., description='Edge target vertex name.')
class-attribute
instance-attribute
¶
Functions:¶
append_index(indexes, index, *, owner)
¶
Register index unless already present, refusing a contradictory restatement.
Idempotent on the full definition so repeated schema resolution does not
accumulate duplicates. Deduplicating on the field-set alone -- as this did
-- silently kept whichever unique arrived first for a field-set indexed
two ways, and which one that was depended on resolution order.
Source code in graflo/architecture/schema/database_features.py
index_identity(index)
¶
Everything about an index except its cosmetic name.
Indexes are addressed by field list (RemoveVertexIndexesOp), so two
entries differing only by name are one index; two differing on uniqueness,
type or sparsity are two contradictory claims about one field-set.