test_cte_parse/
test_cte_parse.rs1use qail_core::parser::parse;
3use qail_core::transpiler::ToSql;
4
5fn main() {
6 let query = "with stats as (get whatsapp_messages fields count(distinct phone_number) as total_contacts, count(*) as total_messages, count(*) filter (where direction = 'outbound' and created_at > now() - 24h) as messages_sent_24h, count(*) filter (where direction = 'inbound' and created_at > now() - 24h) as messages_received_24h, count(*) filter (where direction = 'inbound' and status = 'received') as unread_messages, count(*) filter (where direction = 'outbound' and created_at > now() - 24h and status in ('delivered', 'read')) as successful_deliveries_24h) get stats";
8
9 println!("Complete WhatsApp Insights Query (6 columns):");
10 match parse(query) {
11 Ok(cmd) => println!("✅\n{}", cmd.to_sql()),
12 Err(e) => println!("❌ {}", e),
13 }
14}