From 46d0b3cd6454a85b09ee9ac57b88367be76e161c Mon Sep 17 00:00:00 2001 From: discord9 Date: Wed, 8 May 2024 19:07:18 +0800 Subject: [PATCH] fix: table name trying best to get full name --- src/flow/src/transform/plan.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/flow/src/transform/plan.rs b/src/flow/src/transform/plan.rs index a8b3e4c80b..50d9363fca 100644 --- a/src/flow/src/transform/plan.rs +++ b/src/flow/src/transform/plan.rs @@ -115,11 +115,27 @@ impl TypedPlan { Some(RelType::Read(read)) => { if let Some(ReadType::NamedTable(nt)) = &read.as_ref().read_type { let query_ctx = ctx.query_context.clone().unwrap(); - let table_reference = [ - query_ctx.current_catalog().to_string(), - query_ctx.current_schema().to_string(), - nt.names[0].clone(), - ]; + let table_reference = match nt.names.len() { + 1 => [ + query_ctx.current_catalog().to_string(), + query_ctx.current_schema().to_string(), + nt.names[0].clone(), + ], + 2 => [ + query_ctx.current_catalog().to_string(), + nt.names[0].clone(), + nt.names[1].clone(), + ], + 3 => [ + nt.names[0].clone(), + nt.names[1].clone(), + nt.names[2].clone(), + ], + _ => InvalidQuerySnafu { + reason: "Expect table to have name", + } + .fail()?, + }; let table = ctx.table(&table_reference)?; let get_table = Plan::Get { id: crate::expr::Id::Global(table.0),