risinglightdb / risinglight

An educational OLAP database system.
Apache License 2.0
1.61k stars 214 forks source link

chore/binder: add test on binder #809

Closed caicancai closed 11 months ago

caicancai commented 11 months ago

2023-11-15 18-38-36屏幕截图

caicancai commented 11 months ago

I'll see if I can fill in the other tests tomorrow

caicancai commented 11 months ago

@wangrunji0408 Hello, I am very sorry to bother you so late. I have also improved insert and other tests, but I am not sure whether the code should be submitted, because the prefix steps of the test code are the same, will it be very redundant

insert test:

#[cfg(test)]
mod tests {
    use std::sync::Arc;

    use super::*;
    use crate::catalog::{ColumnCatalog, RootCatalog};
    use crate::parser::parse;
    use crate::binder::Binder;

    #[test]
    fn bind_drop_table() {
        let catalog = Arc::new(RootCatalog::new());
        let col_desc = DataTypeKind::Int32.not_null().to_column("a".into());
        let col_catalog = ColumnCatalog::new(0, col_desc);
        catalog
            .add_table(0, "t".into(), vec![col_catalog], false, vec![])
            .unwrap();

        let stmts = parse("insert into t (a) values (1)").unwrap();
        println!("{:?}", stmts);
        let mut binder = Binder::new(catalog);
        for stmt in stmts {
            let plan = binder.bind(stmt).unwrap();
            println!("{}", plan.pretty(10));
        }
    }
}
caicancai commented 11 months ago

2023-11-16 09-44-04屏幕截图

caicancai commented 11 months ago

expr seems to have to write test to verify everything is a bit complicated. 🤪

caicancai commented 11 months ago

@wangrunji0408 hi, excuse me. if you have time, could you review my two pr? I can close this pr if there is a problem

skyzh commented 11 months ago

will take a look this weekend :)

caicancai commented 11 months ago

I don't think these new tests are actually testing + comparing with some expected result? In this case, it looks better to make this test part of sqlplannertest, so that we can find regressions across commits.

thank your review and advice