mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-26 09:50:40 +00:00
chore: update datafusion family (#6675)
* chore: update datafusion family Signed-off-by: luofucong <luofc@foxmail.com> * fix ci Signed-off-by: luofucong <luofc@foxmail.com> * use official otel-arrow-rust Signed-off-by: luofucong <luofc@foxmail.com> * rebase Signed-off-by: luofucong <luofc@foxmail.com> * use the official orc-rust Signed-off-by: luofucong <luofc@foxmail.com> * resolve PR comments Signed-off-by: luofucong <luofc@foxmail.com> * remove the empty lines Signed-off-by: luofucong <luofc@foxmail.com> * try following PR comments Signed-off-by: luofucong <luofc@foxmail.com> --------- Signed-off-by: luofucong <luofc@foxmail.com>
This commit is contained in:
@@ -24,7 +24,7 @@ use datafusion::error::Result as DatafusionResult;
|
||||
use datafusion::logical_expr::{LogicalPlan, LogicalPlanBuilder};
|
||||
use datafusion_common::{Column, TableReference};
|
||||
use datafusion_expr::dml::InsertOp;
|
||||
use datafusion_expr::{col, DmlStatement, WriteOp};
|
||||
use datafusion_expr::{col, DmlStatement, TableSource, WriteOp};
|
||||
pub use expr::{build_filter_from_timestamp, build_same_type_ts_filter};
|
||||
use snafu::ResultExt;
|
||||
|
||||
@@ -131,7 +131,7 @@ pub fn breakup_insert_plan(
|
||||
/// create a `insert into table_name <input>` logical plan
|
||||
pub fn add_insert_to_logical_plan(
|
||||
table_name: TableName,
|
||||
table_schema: datafusion_common::DFSchemaRef,
|
||||
target: Arc<dyn TableSource>,
|
||||
input: LogicalPlan,
|
||||
) -> Result<LogicalPlan> {
|
||||
let table_name = TableReference::Full {
|
||||
@@ -142,7 +142,7 @@ pub fn add_insert_to_logical_plan(
|
||||
|
||||
let plan = LogicalPlan::Dml(DmlStatement::new(
|
||||
table_name,
|
||||
table_schema,
|
||||
target,
|
||||
WriteOp::Insert(InsertOp::Append),
|
||||
Arc::new(input),
|
||||
));
|
||||
|
||||
@@ -87,29 +87,31 @@ fn timestamp_to_literal(timestamp: &Timestamp) -> Expr {
|
||||
TimeUnit::Microsecond => ScalarValue::TimestampMicrosecond(Some(timestamp.value()), None),
|
||||
TimeUnit::Nanosecond => ScalarValue::TimestampNanosecond(Some(timestamp.value()), None),
|
||||
};
|
||||
Expr::Literal(scalar_value)
|
||||
Expr::Literal(scalar_value, None)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use datafusion_expr::Literal;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_timestamp_to_literal() {
|
||||
let timestamp = Timestamp::new(123456789, TimeUnit::Second);
|
||||
let expected = Expr::Literal(ScalarValue::TimestampSecond(Some(123456789), None));
|
||||
let expected = ScalarValue::TimestampSecond(Some(123456789), None).lit();
|
||||
assert_eq!(timestamp_to_literal(×tamp), expected);
|
||||
|
||||
let timestamp = Timestamp::new(123456789, TimeUnit::Millisecond);
|
||||
let expected = Expr::Literal(ScalarValue::TimestampMillisecond(Some(123456789), None));
|
||||
let expected = ScalarValue::TimestampMillisecond(Some(123456789), None).lit();
|
||||
assert_eq!(timestamp_to_literal(×tamp), expected);
|
||||
|
||||
let timestamp = Timestamp::new(123456789, TimeUnit::Microsecond);
|
||||
let expected = Expr::Literal(ScalarValue::TimestampMicrosecond(Some(123456789), None));
|
||||
let expected = ScalarValue::TimestampMicrosecond(Some(123456789), None).lit();
|
||||
assert_eq!(timestamp_to_literal(×tamp), expected);
|
||||
|
||||
let timestamp = Timestamp::new(123456789, TimeUnit::Nanosecond);
|
||||
let expected = Expr::Literal(ScalarValue::TimestampNanosecond(Some(123456789), None));
|
||||
let expected = ScalarValue::TimestampNanosecond(Some(123456789), None).lit();
|
||||
assert_eq!(timestamp_to_literal(×tamp), expected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ use datafusion_expr::function::{AccumulatorArgs, StateFieldsArgs};
|
||||
use datafusion_expr::{
|
||||
Accumulator, AccumulatorFactoryFunction, AggregateUDF as DfAggregateUdf, AggregateUDFImpl,
|
||||
};
|
||||
use datatypes::arrow::datatypes::DataType as ArrowDataType;
|
||||
use datatypes::arrow::datatypes::{DataType as ArrowDataType, FieldRef};
|
||||
use datatypes::data_type::DataType;
|
||||
|
||||
use crate::function::{
|
||||
@@ -129,14 +129,14 @@ impl AggregateUDFImpl for DfUdafAdapter {
|
||||
(self.accumulator)(acc_args)
|
||||
}
|
||||
|
||||
fn state_fields(&self, args: StateFieldsArgs) -> Result<Vec<Field>> {
|
||||
fn state_fields(&self, args: StateFieldsArgs) -> Result<Vec<FieldRef>> {
|
||||
let state_types = self.creator.state_types()?;
|
||||
let fields = state_types
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(i, t)| {
|
||||
let name = format!("{}_{i}", args.name);
|
||||
Field::new(name, t.as_arrow_type(), true)
|
||||
Arc::new(Field::new(name, t.as_arrow_type(), true))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
Ok(fields)
|
||||
|
||||
Reference in New Issue
Block a user