diff --git a/ballista/rust/core/proto/ballista.proto b/ballista/rust/core/proto/ballista.proto index b6bc5d09c392..381221f38d27 100644 --- a/ballista/rust/core/proto/ballista.proto +++ b/ballista/rust/core/proto/ballista.proto @@ -33,7 +33,7 @@ message LogicalExprNode { oneof ExprType { // column references string column_name = 1; - + // alias AliasNode alias = 2; @@ -42,15 +42,15 @@ message LogicalExprNode { // binary expressions BinaryExprNode binary_expr = 4; - + // aggregate expressions AggregateExprNode aggregate_expr = 5; - + // null checks IsNull is_null_expr = 6; IsNotNull is_not_null_expr = 7; Not not_expr = 8; - + BetweenNode between = 9; CaseNode case_ = 10; CastNode cast = 11; @@ -130,6 +130,7 @@ enum ScalarFunction { SHA256 = 30; SHA384 = 31; SHA512 = 32; + LN = 33; } message ScalarFunctionNode { @@ -361,7 +362,7 @@ message CsvScanExecNode { bool has_header = 5; uint32 batch_size = 6; string delimiter = 7; - + // partition filenames repeated string filename = 8; } @@ -466,7 +467,7 @@ message Action { // Fetch a partition from an executor PartitionId fetch_partition = 3; } - + // configuration settings repeated KeyValuePair settings = 100; } @@ -742,10 +743,10 @@ message ScalarValue{ } } -// Contains all valid datafusion scalar type except for +// Contains all valid datafusion scalar type except for // List enum PrimitiveScalarType{ - + BOOL = 0; // arrow::Type::BOOL UINT8 = 1; // arrow::Type::UINT8 INT8 = 2; // arrow::Type::INT8 @@ -777,7 +778,7 @@ message ScalarListType{ PrimitiveScalarType deepest_type = 2; } -// Broke out into multiple message types so that type +// Broke out into multiple message types so that type // metadata did not need to be in separate message //All types that are of the empty message types contain no additional metadata // about the type @@ -794,7 +795,7 @@ message ArrowType{ EmptyMessage UINT64 =9; EmptyMessage INT64 =10 ; EmptyMessage FLOAT16 =11 ; - EmptyMessage FLOAT32 =12 ; + EmptyMessage FLOAT32 =12 ; EmptyMessage FLOAT64 =13 ; EmptyMessage UTF8 =14 ; EmptyMessage LARGE_UTF8 = 32; @@ -824,7 +825,7 @@ message ArrowType{ //Useful for representing an empty enum variant in rust // E.G. enum example{One, Two(i32)} -// maps to +// maps to // message example{ // oneof{ // EmptyMessage One = 1; diff --git a/ballista/rust/core/src/serde/logical_plan/from_proto.rs b/ballista/rust/core/src/serde/logical_plan/from_proto.rs index 18a85d2796cf..ab7c55f4500d 100644 --- a/ballista/rust/core/src/serde/logical_plan/from_proto.rs +++ b/ballista/rust/core/src/serde/logical_plan/from_proto.rs @@ -28,8 +28,8 @@ use crate::{convert_box_required, convert_required}; use arrow::datatypes::{DataType, Field, Schema}; use datafusion::logical_plan::{ - abs, acos, asin, atan, ceil, cos, exp, floor, log10, log2, round, signum, sin, sqrt, - tan, trunc, Expr, JoinType, LogicalPlan, LogicalPlanBuilder, Operator, + abs, acos, asin, atan, ceil, cos, exp, floor, ln, log10, log2, round, signum, sin, + sqrt, tan, trunc, Expr, JoinType, LogicalPlan, LogicalPlanBuilder, Operator, }; use datafusion::physical_plan::aggregates::AggregateFunction; use datafusion::physical_plan::csv::CsvReadOptions; @@ -1013,6 +1013,7 @@ impl TryInto for &protobuf::LogicalExprNode { protobuf::ScalarFunction::Log2 => { Ok(log2((&expr.expr[0]).try_into()?)) } + protobuf::ScalarFunction::Ln => Ok(ln((&expr.expr[0]).try_into()?)), protobuf::ScalarFunction::Log10 => { Ok(log10((&expr.expr[0]).try_into()?)) } diff --git a/ballista/rust/core/src/serde/logical_plan/to_proto.rs b/ballista/rust/core/src/serde/logical_plan/to_proto.rs index 560578df9f5b..de4b86e38413 100644 --- a/ballista/rust/core/src/serde/logical_plan/to_proto.rs +++ b/ballista/rust/core/src/serde/logical_plan/to_proto.rs @@ -1200,6 +1200,7 @@ impl TryInto for &BuiltinScalarFunction { BuiltinScalarFunction::Atan => Ok(protobuf::ScalarFunction::Atan), BuiltinScalarFunction::Exp => Ok(protobuf::ScalarFunction::Exp), BuiltinScalarFunction::Log => Ok(protobuf::ScalarFunction::Log), + BuiltinScalarFunction::Ln => Ok(protobuf::ScalarFunction::Ln), BuiltinScalarFunction::Log10 => Ok(protobuf::ScalarFunction::Log10), BuiltinScalarFunction::Floor => Ok(protobuf::ScalarFunction::Floor), BuiltinScalarFunction::Ceil => Ok(protobuf::ScalarFunction::Ceil), diff --git a/datafusion/src/logical_plan/expr.rs b/datafusion/src/logical_plan/expr.rs index fa9b9e0a2490..3365bf260323 100644 --- a/datafusion/src/logical_plan/expr.rs +++ b/datafusion/src/logical_plan/expr.rs @@ -1086,9 +1086,9 @@ unary_scalar_expr!(Trunc, trunc); unary_scalar_expr!(Abs, abs); unary_scalar_expr!(Signum, signum); unary_scalar_expr!(Exp, exp); -unary_scalar_expr!(Log, ln); unary_scalar_expr!(Log2, log2); unary_scalar_expr!(Log10, log10); +unary_scalar_expr!(Ln, ln); // string functions unary_scalar_expr!(Ascii, ascii); diff --git a/datafusion/src/physical_plan/functions.rs b/datafusion/src/physical_plan/functions.rs index 56365fec1dc8..960d7c5d8e0d 100644 --- a/datafusion/src/physical_plan/functions.rs +++ b/datafusion/src/physical_plan/functions.rs @@ -102,7 +102,9 @@ pub enum BuiltinScalarFunction { Exp, /// floor Floor, - /// log, also known as ln + /// ln, Natural logarithm + Ln, + /// log, same as log10 Log, /// log10 Log10, @@ -222,6 +224,7 @@ impl FromStr for BuiltinScalarFunction { "cos" => BuiltinScalarFunction::Cos, "exp" => BuiltinScalarFunction::Exp, "floor" => BuiltinScalarFunction::Floor, + "ln" => BuiltinScalarFunction::Ln, "log" => BuiltinScalarFunction::Log, "log10" => BuiltinScalarFunction::Log10, "log2" => BuiltinScalarFunction::Log2, @@ -633,6 +636,7 @@ pub fn return_type( | BuiltinScalarFunction::Exp | BuiltinScalarFunction::Floor | BuiltinScalarFunction::Log + | BuiltinScalarFunction::Ln | BuiltinScalarFunction::Log10 | BuiltinScalarFunction::Log2 | BuiltinScalarFunction::Round @@ -721,7 +725,8 @@ pub fn create_physical_expr( BuiltinScalarFunction::Cos => math_expressions::cos, BuiltinScalarFunction::Exp => math_expressions::exp, BuiltinScalarFunction::Floor => math_expressions::floor, - BuiltinScalarFunction::Log => math_expressions::ln, + BuiltinScalarFunction::Log => math_expressions::log10, + BuiltinScalarFunction::Ln => math_expressions::ln, BuiltinScalarFunction::Log10 => math_expressions::log10, BuiltinScalarFunction::Log2 => math_expressions::log2, BuiltinScalarFunction::Round => math_expressions::round, diff --git a/datafusion/src/physical_plan/math_expressions.rs b/datafusion/src/physical_plan/math_expressions.rs index 382a15f8ccf6..72b4f102f662 100644 --- a/datafusion/src/physical_plan/math_expressions.rs +++ b/datafusion/src/physical_plan/math_expressions.rs @@ -113,6 +113,6 @@ math_unary_function!("trunc", trunc); math_unary_function!("abs", abs); math_unary_function!("signum", signum); math_unary_function!("exp", exp); -math_unary_function!("log", ln); +math_unary_function!("ln", ln); math_unary_function!("log2", log2); math_unary_function!("log10", log10);