test_cte_parse/
test_cte_parse.rs

1/// Test full WhatsApp insights query parsing
2use qail_core::parser::parse;
3use qail_core::transpiler::ToSql;
4
5fn main() {
6    // Complete WhatsApp insights query with all 6 columns
7    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}