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

Method assert

benchmarks/src/sql_benchmark.rs:167–186  ·  view source on GitHub ↗

Executes the `assert` queries and compares actual results against expected values. Each `assert` query must be followed by a result table (separated by `----`) in the benchmark file. The assertion passes only if the returned record batches exactly match the expected rows. # Errors Returns an error if any `assert` query fails, or if the actual and expected results differ in row count or cell val

(&mut self, ctx: &SessionContext)

Source from the content-addressed store, hash-verified

165 /// Returns an error if any `assert` query fails, or if the actual and
166 /// expected results differ in row count or cell values.
167 pub async fn assert(&mut self, ctx: &SessionContext) -> Result<()> {
168 info!("Running assertions...");
169
170 for assert_query in &self.assert_queries {
171 let query = &assert_query.query;
172
173 info!("Executing assert query {query}");
174
175 let result = ctx.sql(query).await?.collect().await?;
176 let formatted_actual_results = format_record_batches(&result)?;
177
178 Self::compare_results(
179 assert_query,
180 &formatted_actual_results,
181 &assert_query.expected_result,
182 )?;
183 }
184
185 Ok(())
186 }
187
188 /// Executes the `run` queries, optionally saving results for later
189 /// verification. If there are multiple queries only the results for

Calls 3

format_record_batchesFunction · 0.85
collectMethod · 0.80
sqlMethod · 0.80

Tested by

no test coverage detected