@@ -162,6 +162,7 @@ enum TableFormat {
162162}
163163
164164impl TableFormat {
165+ #[ allow( dead_code) ]
165166 fn as_sql_using ( self ) -> & ' static str {
166167 match self {
167168 Self :: Parquet => "PARQUET" ,
@@ -182,6 +183,7 @@ impl TableFormat {
182183
183184#[ derive( Debug , Clone ) ]
184185struct RunState {
186+ #[ allow( dead_code) ]
185187 table_format : TableFormat ,
186188 created_tables : Vec < String > ,
187189 cluster_id : Option < String > ,
@@ -384,6 +386,7 @@ impl DatabricksAdapter {
384386 )
385387 }
386388
389+ #[ allow( dead_code) ]
387390 fn sql_type_for_arrow ( data_type : & DataType ) -> Result < String > {
388391 match data_type {
389392 DataType :: Boolean => Ok ( "BOOLEAN" . to_string ( ) ) ,
@@ -408,6 +411,7 @@ impl DatabricksAdapter {
408411 }
409412 }
410413
414+ #[ allow( dead_code) ]
411415 fn create_table_ddl (
412416 & self ,
413417 table_name : & str ,
@@ -436,6 +440,23 @@ impl DatabricksAdapter {
436440 ) )
437441 }
438442
443+ /// Build a CTAS statement that creates the table by reading parquet files
444+ /// from S3.
445+ ///
446+ /// ```sql
447+ /// CREATE OR REPLACE TABLE catalog.schema.table
448+ /// AS SELECT * FROM parquet.`s3://bucket/prefix/scenario/version/tables/table/`
449+ /// ```
450+ fn create_table_ctas ( & self , table_name : & str ) -> String {
451+ let source_uri = format ! (
452+ "s3://spiceai-public-datasets/data-gen/tpch/4/tables/{table_name}/"
453+ ) ;
454+ format ! (
455+ "CREATE OR REPLACE TABLE {} AS SELECT * FROM parquet.`{source_uri}`" ,
456+ self . lakebase_table_full_name( table_name) ,
457+ )
458+ }
459+
439460 fn table_format_from_setup_metadata (
440461 & self ,
441462 metadata : & HashMap < String , Value > ,
@@ -1084,19 +1105,11 @@ impl Handler for DatabricksAdapter {
10841105 } ,
10851106 ) ;
10861107
1087- let table_format = {
1088- let state = self
1089- . runs
1090- . get ( & run_id)
1091- . ok_or_else ( || format ! ( "Unknown run_id: {run_id}" ) ) ?;
1092- state. table_format
1093- } ;
1094-
10951108 let mut created_tables = Vec :: with_capacity ( datasets. len ( ) ) ;
10961109
10971110 match self . config . variant {
10981111 DatabricksVariant :: Databricks | DatabricksVariant :: Lakebase => {
1099- for ( table_name, dataset_cfg ) in datasets {
1112+ for ( table_name, _dataset_cfg ) in datasets {
11001113 let drop_sql = format ! (
11011114 "DROP TABLE IF EXISTS {}" ,
11021115 self . lakebase_table_full_name( & table_name)
@@ -1107,11 +1120,7 @@ impl Handler for DatabricksAdapter {
11071120 )
11081121 } ) ?;
11091122
1110- let create_sql = self
1111- . create_table_ddl ( & table_name, & dataset_cfg, table_format)
1112- . map_err ( |e| {
1113- format ! ( "Failed to build Lakebase table DDL for '{table_name}': {e}" )
1114- } ) ?;
1123+ let create_sql = self . create_table_ctas ( & table_name) ;
11151124
11161125 eprintln ! ( "[databricks-adapter] create_table '{table_name}': {create_sql}" ) ;
11171126
0 commit comments