A memory table can be ordered by multiple expressions simultaneously. [`EquivalenceProperties`] keeps track of expressions that describe the global ordering of the schema. These columns are not necessarily same; e.g. ```text ┌-------┐ | a | b | |---|---| | 1 | 9 | | 2 | 8 | | 3 | 7 | | 5 | 5 | └---┴---┘ ``` where both `a ASC` and `b DESC` can describe the table ordering. With [`EquivalenceProperti
(
mut self,
mut sort_information: Vec<LexOrdering>,
)
| 433 | /// Note that if there is an internal projection, that projection will be |
| 434 | /// also applied to the given `sort_information`. |
| 435 | pub fn try_with_sort_information( |
| 436 | mut self, |
| 437 | mut sort_information: Vec<LexOrdering>, |
| 438 | ) -> Result<Self> { |
| 439 | // All sort expressions must refer to the original schema |
| 440 | let fields = self.schema.fields(); |
| 441 | let ambiguous_column = sort_information |
| 442 | .iter() |
| 443 | .flat_map(|ordering| ordering.clone()) |
| 444 | .flat_map(|expr| collect_columns(&expr.expr)) |
| 445 | .find(|col| { |
| 446 | fields |
| 447 | .get(col.index()) |
| 448 | .map(|field| field.name() != col.name()) |
| 449 | .unwrap_or(true) |
| 450 | }); |
| 451 | assert_or_internal_err!( |
| 452 | ambiguous_column.is_none(), |
| 453 | "Column {:?} is not found in the original schema of the MemorySourceConfig", |
| 454 | ambiguous_column.as_ref().unwrap() |
| 455 | ); |
| 456 | |
| 457 | // If there is a projection on the source, we also need to project orderings |
| 458 | if self.projection.is_some() { |
| 459 | sort_information = |
| 460 | project_orderings(&sort_information, &self.projected_schema); |
| 461 | } |
| 462 | |
| 463 | self.sort_information = sort_information; |
| 464 | Ok(self) |
| 465 | } |
| 466 | |
| 467 | /// Arc clone of ref to original schema |
| 468 | pub fn original_schema(&self) -> SchemaRef { |