@@ -123,6 +123,12 @@ pub fn scan_df_jsonl(
123
123
)
124
124
}
125
125
126
+ pub fn scan_df_json ( path : impl AsRef < Path > ) -> Result < LazyFrame , OxenError > {
127
+ // cannot lazy read json array
128
+ let df = read_df_json ( path) ?;
129
+ Ok ( df. lazy ( ) )
130
+ }
131
+
126
132
pub fn read_df_parquet ( path : impl AsRef < Path > ) -> Result < DataFrame , OxenError > {
127
133
let path = path. as_ref ( ) ;
128
134
let error_str = format ! ( "Could not read tabular data from path {path:?}" ) ;
@@ -876,6 +882,7 @@ pub fn scan_df(
876
882
Some ( extension) => match extension {
877
883
"ndjson" => scan_df_jsonl ( path, opts, total_rows) ,
878
884
"jsonl" => scan_df_jsonl ( path, opts, total_rows) ,
885
+ "json" => scan_df_json ( path) ,
879
886
"csv" | "data" => {
880
887
let delimiter = sniff_db_csv_delimiter ( & path, opts) ?;
881
888
scan_df_csv ( path, delimiter, opts, total_rows)
@@ -924,6 +931,13 @@ pub fn get_size(path: impl AsRef<Path>) -> Result<DataFrameSize, OxenError> {
924
931
let height = reader. _num_rows ( ) ?;
925
932
Ok ( DataFrameSize { width, height } )
926
933
}
934
+ "json" => {
935
+ let df = lazy_df
936
+ . collect ( )
937
+ . map_err ( |_| OxenError :: basic_str ( "Could not collect json df" ) ) ?;
938
+ let height = df. height ( ) ;
939
+ Ok ( DataFrameSize { width, height } )
940
+ }
927
941
_ => Err ( OxenError :: basic_str ( err) ) ,
928
942
} ,
929
943
None => Err ( OxenError :: basic_str ( err) ) ,
0 commit comments