@@ -29,7 +29,8 @@ use crate::coordinator::plan::{
2929use crate :: coordinator:: statement:: { ConfigSource , FunctionSource } ;
3030use crate :: runtime:: streaming:: job:: JobManager ;
3131use crate :: runtime:: taskexecutor:: TaskManager ;
32- use crate :: sql:: schema:: { show_create_stream_table, StreamTable } ;
32+ use crate :: sql:: schema:: table:: Table as CatalogTable ;
33+ use crate :: sql:: schema:: show_create_catalog_table;
3334use crate :: storage:: stream_catalog:: CatalogManager ;
3435
3536#[ derive( Error , Debug ) ]
@@ -201,7 +202,10 @@ impl PlanVisitor for Executor {
201202 _plan : & ShowCatalogTablesPlan ,
202203 _context : & PlanVisitorContext ,
203204 ) -> PlanVisitorResult {
204- let tables = self . catalog_manager . list_stream_tables ( ) ;
205+ let tables = match self . catalog_manager . list_catalog_tables ( ) {
206+ Ok ( tables) => tables,
207+ Err ( e) => return PlanVisitorResult :: Execute ( Err ( ExecuteError :: Internal ( e. to_string ( ) ) ) ) ,
208+ } ;
205209 let n = tables. len ( ) ;
206210 let result = ExecuteResult :: ok_with_data (
207211 format ! ( "{n} stream catalog table(s)" ) ,
@@ -218,14 +222,15 @@ impl PlanVisitor for Executor {
218222 let execute = || -> Result < ExecuteResult , ExecuteError > {
219223 let t = self
220224 . catalog_manager
221- . get_stream_table ( & plan. table_name )
225+ . get_catalog_table ( & plan. table_name )
226+ . map_err ( |e| ExecuteError :: Internal ( e. to_string ( ) ) ) ?
222227 . ok_or_else ( || {
223228 ExecuteError :: Validation ( format ! (
224229 "Table '{}' not found in stream catalog" ,
225230 plan. table_name
226231 ) )
227232 } ) ?;
228- let ddl = show_create_stream_table ( t. as_ref ( ) ) ;
233+ let ddl = show_create_catalog_table ( t. as_ref ( ) ) ;
229234 Ok ( ExecuteResult :: ok_with_data (
230235 format ! ( "SHOW CREATE TABLE {}" , plan. table_name) ,
231236 ShowCreateTableResult :: new ( plan. table_name . clone ( ) , ddl) ,
@@ -284,21 +289,13 @@ impl PlanVisitor for Executor {
284289 _context : & PlanVisitorContext ,
285290 ) -> PlanVisitorResult {
286291 let execute = || -> Result < ExecuteResult , ExecuteError > {
287- let ( table_name, if_not_exists, stream_table ) = match & plan. body {
292+ let ( table_name, if_not_exists, catalog_table ) = match & plan. body {
288293 CreateTablePlanBody :: ConnectorSource {
289294 source_table,
290295 if_not_exists,
291296 } => {
292297 let table_name = source_table. name ( ) . to_string ( ) ;
293- let schema = Arc :: new ( source_table. produce_physical_schema ( ) ) ;
294- let table_instance = StreamTable :: Source {
295- name : table_name. clone ( ) ,
296- connector : source_table. connector ( ) . to_string ( ) ,
297- schema,
298- event_time_field : source_table. event_time_field ( ) . map ( str:: to_string) ,
299- watermark_field : source_table. stream_catalog_watermark_field ( ) ,
300- with_options : source_table. catalog_with_options ( ) . clone ( ) ,
301- } ;
298+ let table_instance = CatalogTable :: ConnectorTable ( source_table. clone ( ) ) ;
302299 ( table_name, * if_not_exists, table_instance)
303300 }
304301 CreateTablePlanBody :: DataFusion ( _) => {
@@ -309,14 +306,14 @@ impl PlanVisitor for Executor {
309306 }
310307 } ;
311308
312- if if_not_exists && self . catalog_manager . has_stream_table ( & table_name) {
309+ if if_not_exists && self . catalog_manager . has_catalog_table ( & table_name) {
313310 return Ok ( ExecuteResult :: ok ( format ! (
314311 "Table '{table_name}' already exists (skipped)"
315312 ) ) ) ;
316313 }
317314
318315 self . catalog_manager
319- . add_table ( stream_table )
316+ . add_catalog_table ( catalog_table )
320317 . map_err ( |e| {
321318 ExecuteError :: Internal ( format ! (
322319 "Failed to register connector source table '{}': {}" ,
@@ -338,15 +335,6 @@ impl PlanVisitor for Executor {
338335 _context : & PlanVisitorContext ,
339336 ) -> PlanVisitorResult {
340337 let execute = || -> Result < ExecuteResult , ExecuteError > {
341- let sink = StreamTable :: Sink {
342- name : plan. name . clone ( ) ,
343- program : plan. program . clone ( ) ,
344- } ;
345-
346- self . catalog_manager
347- . add_table ( sink)
348- . map_err ( |e| ExecuteError :: Internal ( e. to_string ( ) ) ) ?;
349-
350338 let fs_program: FsProgram = plan. program . clone ( ) . into ( ) ;
351339 let job_manager: Arc < JobManager > = Arc :: clone ( & self . job_manager ) ;
352340
@@ -359,7 +347,7 @@ impl PlanVisitor for Executor {
359347 info ! (
360348 job_id = %job_id,
361349 table = %plan. name,
362- "Streaming table registered and job submitted"
350+ "Streaming job submitted"
363351 ) ;
364352
365353 Ok ( ExecuteResult :: ok_with_data (
@@ -398,7 +386,7 @@ impl PlanVisitor for Executor {
398386 ) -> PlanVisitorResult {
399387 let execute = || -> Result < ExecuteResult , ExecuteError > {
400388 self . catalog_manager
401- . drop_table ( & plan. table_name , plan. if_exists )
389+ . drop_catalog_table ( & plan. table_name , plan. if_exists )
402390 . map_err ( |e| ExecuteError :: Internal ( e. to_string ( ) ) ) ?;
403391
404392 Ok ( ExecuteResult :: ok ( format ! (
0 commit comments