Skip to content

Commit 124ea41

Browse files
committed
Updates after rebase
1 parent 6774eea commit 124ea41

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

datafusion/expr/src/expr_schema.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,18 @@ impl ExprSchemable for Expr {
417417
Expr::OuterReferenceColumn(ty, _) => {
418418
Ok(Arc::new(Field::new(&schema_name, ty.clone(), true)))
419419
}
420-
Expr::ScalarVariable(ty, _) => Ok(Arc::new(Field::new(&schema_name, ty.clone(), true))),
420+
Expr::ScalarVariable(ty, _) => {
421+
Ok(Arc::new(Field::new(&schema_name, ty.clone(), true)))
422+
}
421423
Expr::Literal(l, metadata) => {
422-
let mut field = Field::new(&schema_name, l.data_type(), l.is_null();
424+
let mut field = Field::new(&schema_name, l.data_type(), l.is_null());
423425
if let Some(metadata) = metadata {
424-
field = field.with_metadata(metadata.clone());
426+
field = field.with_metadata(
427+
metadata
428+
.iter()
429+
.map(|(k, v)| (k.clone(), v.clone()))
430+
.collect(),
431+
);
425432
}
426433
Ok(Arc::new(field))
427434
}

datafusion/physical-expr/src/expressions/literal.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::sync::Arc;
2424

2525
use crate::physical_expr::PhysicalExpr;
2626

27-
use arrow::datatypes::Field;
27+
use arrow::datatypes::{Field, FieldRef};
2828
use arrow::{
2929
datatypes::{DataType, Schema},
3030
record_batch::RecordBatch,
@@ -39,7 +39,7 @@ use datafusion_expr_common::sort_properties::{ExprProperties, SortProperties};
3939
#[derive(Debug, PartialEq, Eq)]
4040
pub struct Literal {
4141
value: ScalarValue,
42-
field: Field,
42+
field: FieldRef,
4343
}
4444

4545
impl Hash for Literal {
@@ -74,7 +74,10 @@ impl Literal {
7474
field = field.with_metadata(metadata);
7575
}
7676

77-
Self { value, field }
77+
Self {
78+
value,
79+
field: field.into(),
80+
}
7881
}
7982

8083
/// Get the scalar value
@@ -103,8 +106,8 @@ impl PhysicalExpr for Literal {
103106
Ok(self.value.is_null())
104107
}
105108

106-
fn return_field(&self, _input_schema: &Schema) -> Result<Field> {
107-
Ok(self.field.clone())
109+
fn return_field(&self, _input_schema: &Schema) -> Result<FieldRef> {
110+
Ok(Arc::clone(&self.field))
108111
}
109112

110113
fn evaluate(&self, _batch: &RecordBatch) -> Result<ColumnarValue> {

0 commit comments

Comments
 (0)