Skip to content

feat: support for Values #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
temp_table_name added to represent the data source
  • Loading branch information
wszhdshys committed Aug 2, 2025
commit ade4b387179b6c4734c6f984c82e567b2c31af37
12 changes: 6 additions & 6 deletions src/binder/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,8 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
ConstantCalculator.visit(&mut expression)?;

if let Constant(value) = expression {
// 2. 获取当前值的类型
let value_type = value.logical_type();

// 3. 合并类型为最宽类型
inferred_types[col_index] = match &inferred_types[col_index] {
Some(existing) => {
Some(LogicalType::max_logical_type(existing, &value_type)?)
Expand All @@ -200,20 +198,22 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
rows.push(row);
}

let column_ref: Vec<ColumnRef> = inferred_types
let column_refs: Vec<ColumnRef> = inferred_types
.into_iter()
.enumerate()
.map(|(col_index, typ)| {
let typ = typ.ok_or(DatabaseError::InvalidType)?;
Ok(ColumnRef(Arc::new(ColumnCatalog::new(
let mut column_ref = ColumnCatalog::new(
col_index.to_string(),
false,
ColumnDesc::new(typ, None, false, None)?,
))))
);
column_ref.set_ref_table(self.context.temp_table(), ColumnId::default(), true);
Ok(ColumnRef(Arc::new(column_ref)))
})
.collect::<Result<_, DatabaseError>>()?;

Ok(self.bind_values(rows, Arc::new(column_ref)))
Ok(self.bind_values(rows, Arc::new(column_refs)))
}

fn bind_set_cast(
Expand Down
2 changes: 2 additions & 0 deletions src/planner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ impl LogicalPlan {
fn collect_table(plan: &LogicalPlan, results: &mut Vec<TableName>) {
if let Operator::TableScan(op) = &plan.operator {
results.push(op.table_name.clone());
} else if let Operator::Values(op) = &plan.operator {
results.push(op.schema_ref[0].table_name().unwrap().clone());
}
for child in plan.childrens.iter() {
collect_table(child, results);
Expand Down
Loading