datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Remove `From<String>` for `Column`

Open findepi opened this issue 1 year ago • 6 comments

The From & Into conversion system is a very powerful and convenient feature of Rust. It should be used when there is only one obvious conversion from source type to the target.

However, this appears not to be the case for some conversion into Column. Consider example

let field: Field = ....;
Expr::Column(field.name().into()))

It seems to create an expression selecting given field. It is also the simplest conversion from Field to Expr::Column because, From<Field> is not implemented.

However, it doesn't do what it seems it does. The From<&str> for Column invokes name parser and lower-cases the field

These conversions should be removed:

impl From<&str> for Column {
    fn from(c: &str) -> Self {
        Self::from_qualified_name(c)
    }
}

/// Create a column, cloning the string
impl From<&String> for Column {
    fn from(c: &String) -> Self {
        Self::from_qualified_name(c)
    }
}

/// Create a column, reusing the existing string
impl From<String> for Column {
    fn from(c: String) -> Self {
        Self::from_qualified_name(c)
    }
}

Any usages should be replaced with explicit calls to Column::from_qualified_name.

findepi avatar Sep 02 '25 15:09 findepi

This is indeed an implicit conversion. May I help fix this issue? @findepi

zuston avatar Sep 03 '25 06:09 zuston

sure, thanks!

findepi avatar Sep 03 '25 16:09 findepi

Hi, just checking in on this issue. Is anyone actively working on it, or can I pick it up?

ishanema03 avatar Dec 29 '25 09:12 ishanema03

Hi @findepi

I'm implementing this issue and have a question about public API functions. After removing From<String> for Column, public API functions like col(), out_ref_col(), and unnest_column() can no longer accept strings via impl Into<Column> here. I have 2 options

  • Change signatures to impl Into<String>, internally call from_qualified_name() (16 test fixes)
  • Keep impl Into<Column>, require explicit conversion at ~600 call sites but is maybe more aligned with having explicit calls

Which approach is better?

ishanema03 avatar Dec 30 '25 16:12 ishanema03

Hi @findepi I have raised a PR for this issue

ishanema03 avatar Feb 18 '26 16:02 ishanema03

hiii @findepi can I work on this issue

kartik00052 avatar Aug 02 '26 15:08 kartik00052