@@ -502,6 +502,7 @@ impl SessionContext {
502502 cmd. location . clone ( ) ,
503503 options,
504504 provided_schema,
505+ cmd. definition . clone ( ) ,
505506 )
506507 . await ?;
507508 self . return_empty_dataframe ( )
@@ -720,6 +721,7 @@ impl SessionContext {
720721 table_path : impl AsRef < str > ,
721722 options : ListingOptions ,
722723 provided_schema : Option < SchemaRef > ,
724+ sql : Option < String > ,
723725 ) -> Result < ( ) > {
724726 let table_path = ListingTableUrl :: parse ( table_path) ?;
725727 let resolved_schema = match provided_schema {
@@ -729,7 +731,7 @@ impl SessionContext {
729731 let config = ListingTableConfig :: new ( table_path)
730732 . with_listing_options ( options)
731733 . with_schema ( resolved_schema) ;
732- let table = ListingTable :: try_new ( config) ?;
734+ let table = ListingTable :: try_new ( config) ?. with_definition ( sql ) ;
733735 self . register_table ( name, Arc :: new ( table) ) ?;
734736 Ok ( ( ) )
735737 }
@@ -750,6 +752,7 @@ impl SessionContext {
750752 table_path,
751753 listing_options,
752754 options. schema . map ( |s| Arc :: new ( s. to_owned ( ) ) ) ,
755+ None ,
753756 )
754757 . await ?;
755758
@@ -767,8 +770,14 @@ impl SessionContext {
767770 let listing_options =
768771 options. to_listing_options ( self . copied_config ( ) . target_partitions ) ;
769772
770- self . register_listing_table ( name, table_path, listing_options, options. schema )
771- . await ?;
773+ self . register_listing_table (
774+ name,
775+ table_path,
776+ listing_options,
777+ options. schema ,
778+ None ,
779+ )
780+ . await ?;
772781 Ok ( ( ) )
773782 }
774783
@@ -788,7 +797,7 @@ impl SessionContext {
788797 . parquet_pruning ( parquet_pruning)
789798 . to_listing_options ( target_partitions) ;
790799
791- self . register_listing_table ( name, table_path, listing_options, None )
800+ self . register_listing_table ( name, table_path, listing_options, None , None )
792801 . await ?;
793802 Ok ( ( ) )
794803 }
@@ -804,8 +813,14 @@ impl SessionContext {
804813 let listing_options =
805814 options. to_listing_options ( self . copied_config ( ) . target_partitions ) ;
806815
807- self . register_listing_table ( name, table_path, listing_options, options. schema )
808- . await ?;
816+ self . register_listing_table (
817+ name,
818+ table_path,
819+ listing_options,
820+ options. schema ,
821+ None ,
822+ )
823+ . await ?;
809824 Ok ( ( ) )
810825 }
811826
0 commit comments