From 4ab9141a0d18d20fc4f4dfe849690924594a01c4 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Tue, 26 Nov 2024 13:37:57 -0800 Subject: [PATCH] WIP. --- lib/optimization/table_data.go | 11 +++++++++++ lib/typing/columns/columns.go | 11 +++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/optimization/table_data.go b/lib/optimization/table_data.go index 6e1c4a606..334ce43ae 100644 --- a/lib/optimization/table_data.go +++ b/lib/optimization/table_data.go @@ -85,6 +85,17 @@ func (t *TableData) AddInMemoryCol(column columns.Column) { t.inMemoryColumns.AddColumn(column) } +func (t *TableData) GetValidColumns() []columns.Column { + var cols []columns.Column + for _, col := range t.inMemoryColumns.GetColumns() { + if col.IsValid() { + cols = append(cols, col) + } + } + + return cols +} + func (t *TableData) ReadOnlyInMemoryCols() *columns.Columns { if t.inMemoryColumns == nil { return nil diff --git a/lib/typing/columns/columns.go b/lib/typing/columns/columns.go index bb9cb1941..0c160e1af 100644 --- a/lib/typing/columns/columns.go +++ b/lib/typing/columns/columns.go @@ -31,6 +31,10 @@ type Column struct { backfilled bool } +func (c Column) IsValid() bool { + return c.KindDetails.Kind != typing.Invalid.Kind +} + func (c *Column) PrimaryKey() bool { return c.primaryKey } @@ -220,12 +224,11 @@ func (c *Columns) ValidColumns() []Column { var cols []Column for _, col := range c.columns { - if col.KindDetails == typing.Invalid { - continue + if col.IsValid() { + cols = append(cols, col) } - - cols = append(cols, col) } + return cols }