Skip to content

Commit 315f5b9

Browse files
authored
docs: improve Column::normalize_with_schemas docs (apache#4871)
1 parent 39d98f8 commit 315f5b9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

datafusion/common/src/column.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,25 @@ impl Column {
8383
}
8484
}
8585

86-
// Internal implementation of normalize
86+
/// Qualify column if not done yet.
87+
///
88+
/// If this column already has a [relation](Self::relation), it will be returned as is and the given parameters are
89+
/// ignored. Otherwise this will search through the given schemas to find the column. This will use the first schema
90+
/// that matches.
91+
///
92+
/// A schema matches if there is a single column that -- when unqualified -- matches this column. There is an
93+
/// exception for `USING` statements, see below.
94+
///
95+
/// # Using columns
96+
/// Take the following SQL statement:
97+
///
98+
/// ```sql
99+
/// SELECT id FROM t1 JOIN t2 USING(id)
100+
/// ```
101+
///
102+
/// In this case, both `t1.id` and `t2.id` will match unqualified column `id`. To express this possibility, use
103+
/// `using_columns`. Each entry in this array is a set of columns that are bound together via a `USING` clause. So
104+
/// in this example this would be `[{t1.id, t2.id}]`.
87105
pub fn normalize_with_schemas(
88106
self,
89107
schemas: &[&Arc<DFSchema>],

0 commit comments

Comments
 (0)