pub struct Column {
pub relation: Option<TableReference>,
pub name: String,
}
Expand description
A named reference to a qualified field in a schema.
Fields§
§relation: Option<TableReference>
relation/table reference.
name: String
field/column name.
Implementations§
Source§impl Column
impl Column
Sourcepub fn new(
relation: Option<impl Into<TableReference>>,
name: impl Into<String>,
) -> Self
pub fn new( relation: Option<impl Into<TableReference>>, name: impl Into<String>, ) -> Self
Create Column from optional qualifier and name. The optional qualifier, if present, will be parsed and normalized by default.
See full details on TableReference::parse_str
Sourcepub fn new_unqualified(name: impl Into<String>) -> Self
pub fn new_unqualified(name: impl Into<String>) -> Self
Convenience method for when there is no qualifier
Sourcepub fn from_name(name: impl Into<String>) -> Self
pub fn from_name(name: impl Into<String>) -> Self
Create Column from unqualified name.
Alias for Column::new_unqualified
Sourcepub fn from_qualified_name(flat_name: impl Into<String>) -> Self
pub fn from_qualified_name(flat_name: impl Into<String>) -> Self
Deserialize a fully qualified name string into a column
Treats the name as a SQL identifier. For example
foo.BAR
would be parsed to a reference to relation foo
, column name bar
(lower case)
where "foo.BAR"
would be parsed to a reference to column named foo.BAR
Sourcepub fn from_qualified_name_ignore_case(flat_name: impl Into<String>) -> Self
pub fn from_qualified_name_ignore_case(flat_name: impl Into<String>) -> Self
Deserialize a fully qualified name string into a column preserving column text case
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
return the column’s name.
Note: This ignores the relation and returns the column name only.
Sourcepub fn quoted_flat_name(&self) -> String
pub fn quoted_flat_name(&self) -> String
Serialize column into a quoted flat name string
Sourcepub fn normalize_with_schemas_and_ambiguity_check(
self,
schemas: &[&[&DFSchema]],
using_columns: &[HashSet<Column>],
) -> Result<Self>
pub fn normalize_with_schemas_and_ambiguity_check( self, schemas: &[&[&DFSchema]], using_columns: &[HashSet<Column>], ) -> Result<Self>
Qualify column if not done yet.
If this column already has a relation, it will be returned as is and the given parameters are ignored. Otherwise this will search through the given schemas to find the column.
Will check for ambiguity at each level of schemas
.
A schema matches if there is a single column that – when unqualified – matches this column. There is an
exception for USING
statements, see below.
§Using columns
Take the following SQL statement:
SELECT id FROM t1 JOIN t2 USING(id)
In this case, both t1.id
and t2.id
will match unqualified column id
. To express this possibility, use
using_columns
. Each entry in this array is a set of columns that are bound together via a USING
clause. So
in this example this would be [{t1.id, t2.id}]
.
Regarding ambiguity check, schemas
is structured to allow levels of schemas to be passed in.
For example:
schemas = &[
&[schema1, schema2], // first level
&[schema3, schema4], // second level
]
Will search for a matching field in all schemas in the first level. If a matching field according to above mentioned conditions is not found, then will check the next level. If found more than one matching column across all schemas in a level, that isn’t a USING column, will return an error due to ambiguous column.
If checked all levels and couldn’t find field, will return field not found error.
Trait Implementations§
Source§impl From<(Option<&TableReference>, &Arc<Field>)> for Column
impl From<(Option<&TableReference>, &Arc<Field>)> for Column
Create a column, use qualifier and field name
Source§impl From<(Option<&TableReference>, &Field)> for Column
impl From<(Option<&TableReference>, &Field)> for Column
Create a column, use qualifier and field name
Source§impl Ord for Column
impl Ord for Column
Source§impl PartialOrd for Column
impl PartialOrd for Column
impl Eq for Column
impl StructuralPartialEq for Column
Auto Trait Implementations§
impl Freeze for Column
impl RefUnwindSafe for Column
impl Send for Column
impl Sync for Column
impl Unpin for Column
impl UnwindSafe for Column
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.