// use duckdb::arrow::record_batch::RecordBatch; // use duckdb::arrow::util::pretty::print_batches; // use duckdb::Connection; use graphic_walker_parser::parser::workflow::ParserParams; use graphic_walker_parser::parser::{self, model::Dataset}; use parser as kanaries_parser; use sqlparser::dialect::DuckDbDialect; use sqlparser::parser::Parser; use std::fmt::Error; #[allow(unused_variables)] pub fn test_parser(query: &str, sql: &str, dataset: &Dataset) -> Option { test_execute(query, sql, dataset, false) } pub fn test_execute(query: &str, sql: &str, dataset: &Dataset, execute: bool) -> Option { // check dsl parser let res_ast = Parser::parse_sql(&DuckDbDialect {}, sql); dbg!(&res_ast); let parsed_sql = kanaries_parser::parse_dsl( dataset, query, ParserParams { quote_style: Some('"'), as_quote_style: Some('"'), }, ) .unwrap(); if parsed_sql != sql { dbg!(&parsed_sql); return Some(Error {}); } if execute { panic!("not implemented") //create duckdb // let conn = Connection::open_in_memory().unwrap(); // // query table by rows // let mut stmt = conn // .prepare("SELECT id, name, data FROM read_csv('1.csv', AUTO_DETECT=TRUE);") // .unwrap(); // // query table by arrow // let rbs: Vec = stmt.query_arrow([]).unwrap().collect(); // print_batches(&rbs).unwrap(); } None }