Skip to main content

nodedb_sql/parser/array_stmt/
ast.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Typed AST returned by the array-statement parser.
4
5use crate::types_array::{
6    ArrayAttrAst, ArrayCellOrderAst, ArrayCoordLiteral, ArrayDimAst, ArrayInsertRow,
7    ArrayTileOrderAst,
8};
9
10/// Top-level array-statement AST. One variant per surface command.
11#[derive(Debug, Clone, PartialEq)]
12pub enum ArrayStatement {
13    Create(CreateArrayAst),
14    Drop(DropArrayAst),
15    Insert(InsertArrayAst),
16    Delete(DeleteArrayAst),
17    Alter(AlterArrayAst),
18}
19
20/// `ALTER ARRAY <name> SET ( key = value [, key = value]* )`
21///
22/// Supported keys:
23/// - `audit_retain_ms`         — `NULL` or non-negative integer.
24/// - `minimum_audit_retain_ms` — non-negative integer.
25#[derive(Debug, Clone, PartialEq)]
26pub struct AlterArrayAst {
27    pub name: String,
28    /// Key-value pairs from the SET clause. Values are either integer
29    /// literals or NULL (represented as `None`).
30    pub set: Vec<(String, Option<i64>)>,
31}
32
33#[derive(Debug, Clone, PartialEq)]
34pub struct CreateArrayAst {
35    pub name: String,
36    pub dims: Vec<ArrayDimAst>,
37    pub attrs: Vec<ArrayAttrAst>,
38    pub tile_extents: Vec<i64>,
39    pub cell_order: ArrayCellOrderAst,
40    pub tile_order: ArrayTileOrderAst,
41    /// Number of Hilbert-prefix bits used for vShard routing.
42    /// Accepted via optional `WITH (prefix_bits = N)` clause; default 8.
43    pub prefix_bits: u8,
44    /// Audit-retention horizon in milliseconds. `Some(0)` means "retain
45    /// forever"; `None` means non-bitemporal (no purge runs). Maps to
46    /// `ArrayCatalogEntry::audit_retain_ms`.
47    pub audit_retain_ms: Option<u64>,
48    /// Minimum allowed `audit_retain_ms` — compliance floor. `None`
49    /// defaults to 0 (no floor). Validated via `BitemporalRetention::validate()`
50    /// in the planner.
51    pub minimum_audit_retain_ms: Option<u64>,
52}
53
54#[derive(Debug, Clone, PartialEq)]
55pub struct DropArrayAst {
56    pub name: String,
57    pub if_exists: bool,
58}
59
60#[derive(Debug, Clone, PartialEq)]
61pub struct InsertArrayAst {
62    pub name: String,
63    pub rows: Vec<ArrayInsertRow>,
64}
65
66#[derive(Debug, Clone, PartialEq)]
67pub struct DeleteArrayAst {
68    pub name: String,
69    pub coords: Vec<Vec<ArrayCoordLiteral>>,
70}