jonahgao commented on code in PR #15120: URL: https://github.com/apache/datafusion/pull/15120#discussion_r1987556974
########## datafusion/expr/src/expr.rs: ########## @@ -392,11 +392,34 @@ impl Unnest { } /// Alias expression -#[derive(Clone, PartialEq, Eq, PartialOrd, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub struct Alias { pub expr: Box<Expr>, pub relation: Option<TableReference>, pub name: String, + pub metadata: Option<std::collections::HashMap<String, String>>, Review Comment: > yes, only columns/fields have metadata, and it will finally set field's metadata. but how to use field's metadata directly? > > for type_coercion.rs, I can add more code to cover it. I reconsidered it and realized that type_coercion doesn't need to be care about it. It is only used by `Expr::to_field` https://github.com/apache/datafusion/blob/a176aacc92a5b0272690bb48e7084ff5603ef7ad/datafusion/expr/src/expr_schema.rs#L460-L467 Perhaps we should add some comments about its purpose and its connection with `Expr::to_field`. To provide the following convenient API, the current solution makes sense to me. ```rust df.select(vec![col("a").alias_with_metadata("b", Some(metadata))])? ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org