@@ -517,7 +517,7 @@ impl PyRepository {
517517 let repo = Arc :: clone ( & self . 0 ) ;
518518 // This function calls block_on, so we need to allow other thread python to make progress
519519 py. allow_threads ( move || {
520- let version = args_to_version_info ( branch, tag, snapshot_id) ?;
520+ let version = args_to_version_info ( branch, tag, snapshot_id, None ) ?;
521521 let ancestry = pyo3_async_runtimes:: tokio:: get_runtime ( )
522522 . block_on ( async move { repo. ancestry_arc ( & version) . await } )
523523 . map_err ( PyIcechunkStoreError :: RepositoryError ) ?
@@ -701,8 +701,8 @@ impl PyRepository {
701701 to_tag : Option < String > ,
702702 to_snapshot_id : Option < String > ,
703703 ) -> PyResult < PyDiff > {
704- let from = args_to_version_info ( from_branch, from_tag, from_snapshot_id) ?;
705- let to = args_to_version_info ( to_branch, to_tag, to_snapshot_id) ?;
704+ let from = args_to_version_info ( from_branch, from_tag, from_snapshot_id, None ) ?;
705+ let to = args_to_version_info ( to_branch, to_tag, to_snapshot_id, None ) ?;
706706
707707 // This function calls block_on, so we need to allow other thread python to make progress
708708 py. allow_threads ( move || {
@@ -717,17 +717,18 @@ impl PyRepository {
717717 } )
718718 }
719719
720- #[ pyo3( signature = ( * , branch = None , tag = None , snapshot_id = None ) ) ]
720+ #[ pyo3( signature = ( * , branch = None , tag = None , snapshot_id = None , as_of = None ) ) ]
721721 pub fn readonly_session (
722722 & self ,
723723 py : Python < ' _ > ,
724724 branch : Option < String > ,
725725 tag : Option < String > ,
726726 snapshot_id : Option < String > ,
727+ as_of : Option < DateTime < Utc > > ,
727728 ) -> PyResult < PySession > {
728729 // This function calls block_on, so we need to allow other thread python to make progress
729730 py. allow_threads ( move || {
730- let version = args_to_version_info ( branch, tag, snapshot_id) ?;
731+ let version = args_to_version_info ( branch, tag, snapshot_id, as_of ) ?;
731732 let session =
732733 pyo3_async_runtimes:: tokio:: get_runtime ( ) . block_on ( async move {
733734 self . 0
@@ -841,6 +842,7 @@ fn args_to_version_info(
841842 branch : Option < String > ,
842843 tag : Option < String > ,
843844 snapshot : Option < String > ,
845+ as_of : Option < DateTime < Utc > > ,
844846) -> PyResult < VersionInfo > {
845847 let n = [ & branch, & tag, & snapshot] . iter ( ) . filter ( |r| !r. is_none ( ) ) . count ( ) ;
846848 if n > 1 {
@@ -849,8 +851,18 @@ fn args_to_version_info(
849851 ) ) ;
850852 }
851853
852- if let Some ( branch_name) = branch {
853- Ok ( VersionInfo :: BranchTipRef ( branch_name) )
854+ if as_of. is_some ( ) && branch. is_none ( ) {
855+ return Err ( PyValueError :: new_err (
856+ "as_of argument must be provided together with a branch name" ,
857+ ) ) ;
858+ }
859+
860+ if let Some ( branch) = branch {
861+ if let Some ( at) = as_of {
862+ Ok ( VersionInfo :: AsOf { branch, at } )
863+ } else {
864+ Ok ( VersionInfo :: BranchTipRef ( branch) )
865+ }
854866 } else if let Some ( tag_name) = tag {
855867 Ok ( VersionInfo :: TagRef ( tag_name) )
856868 } else if let Some ( snapshot_id) = snapshot {
0 commit comments