MCPcopy Create free account
hub / github.com/apache/datafusion / one_statement_parses_to

Function one_statement_parses_to

datafusion/sql/src/parser.rs:2007–2021  ·  view source on GitHub ↗

Ensures that `sql` parses as a single [Statement] If `canonical` is non empty,this function additionally asserts that: 1. parsing `sql` results in the same [`Statement`] as parsing `canonical`. 2. re-serializing the result of parsing `sql` produces the same `canonical` sql string

(sql: &str, canonical: &str)

Source from the content-addressed store, hash-verified

2005 /// 2. re-serializing the result of parsing `sql` produces the same
2006 /// `canonical` sql string
2007 fn one_statement_parses_to(sql: &str, canonical: &str) -> Statement {
2008 let mut statements = DFParser::parse_sql(sql).unwrap();
2009 assert_eq!(statements.len(), 1);
2010
2011 if sql != canonical {
2012 assert_eq!(DFParser::parse_sql(canonical).unwrap(), statements);
2013 }
2014
2015 let only_statement = statements.pop_front().unwrap();
2016 assert_eq!(
2017 canonical.to_uppercase(),
2018 only_statement.to_string().to_uppercase()
2019 );
2020 only_statement
2021 }
2022
2023 /// Ensures that `sql` parses as a single [Statement], and that
2024 /// re-serializing the parse result produces the same `sql`

Callers 1

verified_stmtFunction · 0.85

Calls 1

pop_frontMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…