pub struct ProjectedColumn {
pub expr: TypedExpr,
pub alias: Option<String>,
}Expand description
A projected column for SELECT clauses.
Contains a typed expression and an optional alias.
§Examples
use alopex_sql::planner::typed_expr::{ProjectedColumn, TypedExpr, TypedExprKind};
use alopex_sql::planner::types::ResolvedType;
use alopex_sql::Span;
// SELECT name AS user_name
let projected = ProjectedColumn {
expr: TypedExpr {
kind: TypedExprKind::ColumnRef {
table: "users".to_string(),
column: "name".to_string(),
column_index: 1,
},
resolved_type: ResolvedType::Text,
span: Span::default(),
},
alias: Some("user_name".to_string()),
};Fields§
§expr: TypedExprThe projected expression.
alias: Option<String>Optional alias (AS name).
Implementations§
Source§impl ProjectedColumn
impl ProjectedColumn
Sourcepub fn with_alias(expr: TypedExpr, alias: String) -> Self
pub fn with_alias(expr: TypedExpr, alias: String) -> Self
Creates a new projected column with an alias.
Sourcepub fn output_name(&self) -> Option<&str>
pub fn output_name(&self) -> Option<&str>
Returns the output name (alias if present, otherwise derived from expression).
Returns:
- The alias if one was specified (e.g.,
SELECT name AS user_name) - The column name for simple column references (e.g.,
SELECT name) Nonefor complex expressions without an alias (e.g.,SELECT 1 + 2)
Complex expressions (function calls, literals, binary operations) return None
because they don’t have a natural name. Use with_alias
to give them an output name.
Trait Implementations§
Source§impl Clone for ProjectedColumn
impl Clone for ProjectedColumn
Source§fn clone(&self) -> ProjectedColumn
fn clone(&self) -> ProjectedColumn
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ProjectedColumn
impl RefUnwindSafe for ProjectedColumn
impl Send for ProjectedColumn
impl Sync for ProjectedColumn
impl Unpin for ProjectedColumn
impl UnwindSafe for ProjectedColumn
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)