fix: improve error messages in check_quantamental_dataframe function

This commit is contained in:
Palash Tyagi 2025-04-16 01:35:48 +01:00
parent 3d2afa01a8
commit 5d2ff3b88d

View File

@ -17,14 +17,15 @@ use std::error::Error;
pub fn check_quantamental_dataframe(df: &DataFrame) -> Result<(), Box<dyn Error>> {
let expected_cols = ["real_date", "cid", "xcat"];
let expected_dtype = [DataType::Date, DataType::String, DataType::String];
let err = "Quantamental DataFrame must have at least 4 columns: 'real_date', 'cid', 'xcat' and one or more metrics.";
for (col, dtype) in expected_cols.iter().zip(expected_dtype.iter()) {
let col = df.column(col);
if col.is_err() {
return Err(format!("Column {:?} not found", col).into());
return Err(format!("{} Column {:?} not found", err, col).into());
}
let col = col?;
if col.dtype() != dtype {
return Err(format!("Column {:?} has wrong dtype", col).into());
return Err(format!("{} Column {:?} has wrong dtype", err, col).into());
}
}
Ok(())