1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// Unified Query Algebra
//
// Copyright (c) 2023-2026 Cognica, Inc.
//
//! Dense output descriptors without retained executor slots or source namespaces.
use super::RowSchema;
impl RowSchema {
/// Select public output metadata in result order. Repeated labels retain their positional identities; a source with a different layout resolves a label through its existing schema index.
pub fn for_result_columns(&self, columns: &[String]) -> Self {
let positions = columns
.iter()
.enumerate()
.map(|(position, column)| {
if self.columns().get(position) == Some(column) {
Some(position)
} else {
self.position(column)
}
})
.collect::<Vec<_>>();
Self::with_column_metadata(
None,
columns.iter().zip(&positions).map(|(column, position)| {
(
column.clone(),
position
.and_then(|position| self.column_type(position))
.cloned(),
position.and_then(|position| self.column_collation(position)),
)
}),
)
.with_record_metadata(positions.into_iter().enumerate().filter_map(
|(output, input)| {
self.record_metadata(input?)
.cloned()
.map(|metadata| (output, metadata))
},
))
}
}