Sign in

    superbigcup325/moonlake/catalog does not have a README file

    BatchStream

    A cursor over the batches of one scan. next returns None exactly once at the end; batches are independent and may be read lazily. Column i of every batch is schema column request.projection[i].

    ScanSource

    pub(open) trait ScanSource {
    fn open(self : Self, request : ScanRequest) -> &BatchStream raise
    SqlError

    fn plan(self : Self, request : ScanRequest) -> ScanPlan raise
    SqlError

    }

    A lazily scanned table: the schema is known up front, the data is not.

    Catalog

    pub struct Catalog {
    tables : Map[String, TableEntry]
    }

    The registry execute reads from: map table name to its entry. Plain values everywhere — build one per execution (or share one across threads that never mutate it).

    Catalog::lookup

    fn Catalog::lookup(self : Catalog, name : String) -> TableEntry?

    Catalog::new

    fn Catalog::new() -> Catalog

    An empty catalog; register scanned tables into it.

    Catalog::register

    fn Catalog::register(self : Catalog, entry : TableEntry) -> Unit

    Register (or replace) a table entry.

    Column

    pub(all) struct Column {
    name : String
    dtype :
    DataType

    } derive(Eq,
    Debug
    )

    One column of a table schema: its name and columnar type.

    Column::equal

    fn Column::equal(Column, Column) -> Bool

    Column::not_equal

    fn Column::not_equal(x : Column, y : Column) -> Bool

    Column::to_repr

    ScanPlan

    pub(all) struct ScanPlan {
    files : Int
    row_groups : Int
    row_groups_skipped : Int
    rows : Int64?
    }

    One part of a scan's work that is known before reading any row: how many files and row groups exist, and how many row groups statistics eliminated.

    ScanPlan::none

    fn ScanPlan::none() -> ScanPlan

    ScanPredicate

    pub(all) struct ScanPredicate {
    column : Int
    op :
    CmpOp

    value :
    Scalar

    }

    One conjunctive predicate hint, in the table's own column numbering (not the projection's): column op constant.

    Hints are advisory. The engine applies the predicate itself, so a source may ignore every hint; a source that uses one must only skip rows that provably cannot satisfy it (that is what Parquet row-group statistics are good for). Column pruning is not a hint: it is the projection.

    ScanRequest

    pub(all) struct ScanRequest {
    projection : Array[Int]
    predicates : Array[ScanPredicate]
    }

    What one scan of a table should produce: the columns the query reads and the predicates it may use to skip data.

    ScanRequest::all

    fn ScanRequest::all(width : Int) -> ScanRequest

    Every column of a width-column table, no predicates: what a whole-file read (a writer, SELECT *) asks for.

    ScanRequest::new

    fn ScanRequest::new(projection : Array[Int], predicates : Array[ScanPredicate]) -> ScanRequest

    TableEntry

    pub(all) struct TableEntry {
    schema : TableSchema
    batches : Array[
    DataBatch
    ]
    source : &ScanSource?
    }

    A registered table: its schema, and either materialized batches or a lazy source. Exactly one of batches / source carries data — a lazy entry keeps batches empty and answers scan from source.

    TableEntry::from_source

    fn TableEntry::from_source(schema : TableSchema, source : &ScanSource) -> TableEntry

    A table that scans its data on demand. Registering it reads no rows.

    TableEntry::is_lazy

    fn TableEntry::is_lazy(self : TableEntry) -> Bool

    Whether this entry streams from a source instead of holding its batches.

    TableEntry::new

    A table already in memory (tests, derived scratch tables, the spill bench).

    TableEntry::plan

    Planning information for EXPLAIN: row groups statistics eliminated. Materialized entries have no plan to report.

    TableEntry::scan

    Produce the batches one query needs: only request.projection columns, in that order, from the materialized batches or from a fresh stream. Predicates are advisory (see ScanPredicate); the caller still filters.

    TableSchema

    pub(all) struct TableSchema {
    table : String
    columns : Array[Column]
    } derive(Eq,
    Debug
    )

    A table's schema: its name and ordered columns. Field names are the user-facing SQL identifiers.

    TableSchema::equal

    fn TableSchema::equal(TableSchema, TableSchema) -> Bool

    TableSchema::index_of

    fn TableSchema::index_of(self : TableSchema, name : String) -> Int?

    TableSchema::not_equal

    fn TableSchema::not_equal(x : TableSchema, y : TableSchema) -> Bool

    SCAN_BATCH_ROWS

    let SCAN_BATCH_ROWS : Int

    Rows per batch a scan source should aim for. Sources may emit a final smaller batch; a zero-row table emits one empty batch so the engine still sees the column layout.

    drain_stream

    Drain a stream to a batch array. The engine stops here because joins, aggregation and sorting are still eager; a source still decides how much it decodes per batch, and a predicate passed to drain_stream keeps the materialized row count below the table's own.

    project_batches

    Drop all but columns (ascending) from each batch, sharing the vectors.