diff --git a/src/array/data_chunk.rs b/src/array/data_chunk.rs index eada10bb..6672c496 100644 --- a/src/array/data_chunk.rs +++ b/src/array/data_chunk.rs @@ -108,6 +108,8 @@ impl DataChunk { self.arrays.iter().map(|a| a.get_estimated_size()).sum() } + /// This function should only be called in plan nodes. If you want to change column name, you + /// should change the plan node, instead of directly attaching a header to the chunk. pub fn set_header(&mut self, header: Vec) { self.header = Some(header); } diff --git a/src/executor/create.rs b/src/executor/create.rs index 1ef683e6..ac8dbe7d 100644 --- a/src/executor/create.rs +++ b/src/executor/create.rs @@ -24,8 +24,7 @@ impl CreateTableExecutor { ) .await?; - let mut chunk = DataChunk::single(0); - chunk.set_header(vec!["$create".to_string()]); + let chunk = DataChunk::single(0); yield chunk } } diff --git a/src/optimizer/plan_nodes/logical_create_table.rs b/src/optimizer/plan_nodes/logical_create_table.rs index 10534d6a..aedad3d7 100644 --- a/src/optimizer/plan_nodes/logical_create_table.rs +++ b/src/optimizer/plan_nodes/logical_create_table.rs @@ -7,7 +7,7 @@ use serde::Serialize; use super::*; use crate::catalog::ColumnCatalog; -use crate::types::{DatabaseId, SchemaId}; +use crate::types::{DataTypeKind, DatabaseId, SchemaId}; /// The logical plan of `CREATE TABLE`. #[derive(Debug, Clone, Serialize)] @@ -54,8 +54,18 @@ impl LogicalCreateTable { } } impl PlanTreeNodeLeaf for LogicalCreateTable {} + impl_plan_tree_node_for_leaf!(LogicalCreateTable); -impl PlanNode for LogicalCreateTable {} + +impl PlanNode for LogicalCreateTable { + fn schema(&self) -> Vec { + vec![ColumnDesc::new( + DataType::new(DataTypeKind::Int(None), false), + "$create".to_string(), + false, + )] + } +} impl fmt::Display for LogicalCreateTable { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/optimizer/plan_nodes/physical_create_table.rs b/src/optimizer/plan_nodes/physical_create_table.rs index 8fe092e1..a224d6fe 100644 --- a/src/optimizer/plan_nodes/physical_create_table.rs +++ b/src/optimizer/plan_nodes/physical_create_table.rs @@ -27,7 +27,11 @@ impl PhysicalCreateTable { impl PlanTreeNodeLeaf for PhysicalCreateTable {} impl_plan_tree_node_for_leaf!(PhysicalCreateTable); -impl PlanNode for PhysicalCreateTable {} +impl PlanNode for PhysicalCreateTable { + fn schema(&self) -> Vec { + self.logical.schema() + } +} impl fmt::Display for PhysicalCreateTable { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {