eliaperantoni commented on code in PR #13664:
URL: https://github.com/apache/datafusion/pull/13664#discussion_r1873102490
##########
datafusion/common/src/column.rs:
##########
@@ -18,22 +18,35 @@
//! Column
use arrow_schema::{Field, FieldRef};
+use sqlparser::tokenizer::Span;
use crate::error::_schema_err;
use crate::utils::{parse_identifiers_normalized, quote_identifier};
use crate::{DFSchema, Result, SchemaError, TableReference};
+use derivative::Derivative;
use std::collections::HashSet;
use std::convert::Infallible;
use std::fmt;
use std::str::FromStr;
/// A named reference to a qualified field in a schema.
-#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
+#[derive(Debug, Clone, Derivative)]
+#[derivative(PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Column {
/// relation/table reference.
pub relation: Option<TableReference>,
/// field/column name.
pub name: String,
+ #[derivative(
Review Comment:
> I also see WithSpan has a similar approach (but that is for wrapping
things with Spans 🤔 )
Ah yes good catch! I could definitely have used `derivative` for `WithSpan`
too. And about `WithSpan`: do you like the general idea of it?
It's meant to be a "sidecar" to get a `Span` all the way to where it's
needed to create a meaningful diagnostic, by attaching it to values that are
sort-of-related, but wouldn't make a lot of sense to add as a struct field.
For example, the two `DataType`s in a binary expression come from the two
expressions in the SQL query, so they (in some sense) relate to a portion of
the code. But putting `span` as a field of `DataType` sounds wrong.
Maybe a better name could be `SpanRelated` or something like that?.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]