Skip to main content

uqa_sql/catalog/
index.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7use crate::ast::Expr;
8
9#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
10#[serde(deny_unknown_fields)]
11pub struct IndexDefinition {
12    #[serde(default, skip_serializing_if = "Option::is_none")]
13    pub catalog: Option<IndexCatalogIdentity>,
14    #[serde(default, skip_serializing_if = "IndexRelationships::is_empty")]
15    pub relationships: IndexRelationships,
16    #[serde(default)]
17    pub included_columns: Vec<String>,
18    #[serde(default)]
19    pub column_order: Vec<crate::ast::IndexColumnOrder>,
20    #[serde(default)]
21    pub key_names: Vec<String>,
22    #[serde(default)]
23    pub key_types: Vec<crate::ast::ColumnType>,
24    #[serde(default)]
25    pub predicate: Option<Box<Expr>>,
26    pub unique: bool,
27    pub nulls_not_distinct: bool,
28}
29
30/// The index address and physical namespace survive SQL name changes. Legacy conversion retains the original physical key without rebuilding postings or evaluating stored expressions.
31#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
32#[serde(deny_unknown_fields)]
33pub struct IndexCatalogIdentity {
34    pub identity: uqa_core::catalog_identity::CatalogObjectIdentity,
35    pub table_object_id: [u8; 16],
36    pub physical_key: String,
37}
38
39pub mod identity;
40
41mod relationships;
42pub use relationships::{can_attach_index, IndexAttachmentShape, IndexRelationships};
43
44mod enforced_key;
45pub use enforced_key::{referenceable_keys, EnforcedKey};
46
47mod output;
48pub mod stored;
49pub use output::format_key_value;