Return an iterator over this [`DataFusionError`] and any other [`DataFusionError`]s in a [`DataFusionError::Collection`]. Sometimes DataFusion is able to collect multiple errors in a SQL query before terminating, e.g. across different expressions in a SELECT statements or different sides of a UNION. This method returns an iterator over all the errors in the collection. For this to work, the top-
(&self)
| 648 | /// For this to work, the top-level error must be a |
| 649 | /// `DataFusionError::Collection`, not something that contains it. |
| 650 | pub fn iter(&self) -> impl Iterator<Item = &DataFusionError> { |
| 651 | struct ErrorIterator<'a> { |
| 652 | queue: VecDeque<&'a DataFusionError>, |
| 653 | } |
| 654 | |
| 655 | impl<'a> Iterator for ErrorIterator<'a> { |
| 656 | type Item = &'a DataFusionError; |
| 657 | |
| 658 | fn next(&mut self) -> Option<Self::Item> { |
| 659 | loop { |
| 660 | let popped = self.queue.pop_front()?; |
| 661 | match popped { |
| 662 | DataFusionError::Collection(errs) => self.queue.extend(errs), |
| 663 | _ => return Some(popped), |
| 664 | } |
| 665 | } |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | let mut queue = VecDeque::new(); |
| 670 | queue.push_back(self); |
| 671 | ErrorIterator { queue } |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | /// A builder for [`DataFusionError`] |