Add an assert_batches_eq!
macro
#7106
Labels
enhancement
Any new improvement worthy of a entry in the changelog
assert_batches_eq!
macro
#7106
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
For unit tests, I want to compare two sets of record batches for equality, and report a readable error message if they aren't. For example:
Because this diffs the pretty-printed output, the output of a test failure can directly be copied into the source code as the expected result.
Describe the solution you'd like
Such a macro already exists in DataFusion. The implementation does not depend on DataFusion internals, so it could be copied into
arrow-rs
with only small adjustments, for example like this:Here, I've already changed it to accept its arguments in either order, and to not require the syntactic noise of
&
orvec!
in the call.Describe alternatives you've considered
Copying the macro into my own code.
Additional context
Additional ergonomics, for bonus points, could include:
Vec<RecordBatch>
es instead of oneVec<RecordBatch>
and one[String]
IntoIterator<Item = RecordBatch>
instead of justVec<RecordBatch>
RecordBatch
es instead of only sequences of themAll of these would require a new trait such as
PrettyFormat
, which would have to be public because it's called from within the macro expansion. It would be implemented forIterator<Item = RecordBatch>
,Vec<String>
and so on.The text was updated successfully, but these errors were encountered: