pub struct Table { /* private fields */ }Expand description
One table.
The rows are a MemoryTable because that is what M0 has. When the storage format arrives the
field changes and this type does not, which is the reason the catalog holds the rows behind a
handle rather than being the rows.
Implementations§
Source§impl Table
impl Table
Sourcepub fn new(name: QualifiedName, columns: Vec<Field>) -> Result<Self>
pub fn new(name: QualifiedName, columns: Vec<Field>) -> Result<Self>
A table with no rows in it.
§Errors
If two columns have the same name, which SQL does not allow and which would make a column
reference ambiguous in a way no error message could explain later. The message is DuckDB’s,
which names the column and not the table and is a catalog error rather than a binder one,
because the same sentence comes out of CREATE TABLE t (a INT, a INT) and out of a
CREATE TABLE ... AS whose column list repeats a name.
Sourcepub fn name(&self) -> &QualifiedName
pub fn name(&self) -> &QualifiedName
The three part name.
Sourcepub fn types(&self) -> Vec<LogicalType>
pub fn types(&self) -> Vec<LogicalType>
The column types, in order.
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Where a column sits, by name, under the identifier rule.
Sourcepub fn rows(&self) -> &MemoryTable
pub fn rows(&self) -> &MemoryTable
The rows.
Sourcepub fn rows_mut(&mut self) -> &mut MemoryTable
pub fn rows_mut(&mut self) -> &mut MemoryTable
The rows, to add to.
This is the way past the constraint check, and the two append methods here are the way
through it. A caller that already knows what it is holding, such as the loader that built
the chunk out of a file the table was declared from, can take this one.
Sourcepub fn append(&mut self, chunk: Chunk) -> Result<()>
pub fn append(&mut self, chunk: Chunk) -> Result<()>
Adds a chunk, refusing a null in a column that said it would not have one.
§Errors
If the chunk does not match the table, or if a NOT NULL column is handed a null. DuckDB
raises a constraint error there and so does this, with the same shape of message, because a
program that catches one by its text is a program rudb has to not surprise.