Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[breaking change] fix 265, log should be log10, and add ln #271

Merged
merged 1 commit into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions ballista/rust/core/proto/ballista.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ message LogicalExprNode {
oneof ExprType {
// column references
string column_name = 1;

// alias
AliasNode alias = 2;

Expand All @@ -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;
Expand Down Expand Up @@ -130,6 +130,7 @@ enum ScalarFunction {
SHA256 = 30;
SHA384 = 31;
SHA512 = 32;
LN = 33;
}

message ScalarFunctionNode {
Expand Down Expand Up @@ -361,7 +362,7 @@ message CsvScanExecNode {
bool has_header = 5;
uint32 batch_size = 6;
string delimiter = 7;

// partition filenames
repeated string filename = 8;
}
Expand Down Expand Up @@ -466,7 +467,7 @@ message Action {
// Fetch a partition from an executor
PartitionId fetch_partition = 3;
}

// configuration settings
repeated KeyValuePair settings = 100;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions ballista/rust/core/src/serde/logical_plan/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1013,6 +1013,7 @@ impl TryInto<Expr> 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()?))
}
Expand Down
1 change: 1 addition & 0 deletions ballista/rust/core/src/serde/logical_plan/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ impl TryInto<protobuf::ScalarFunction> 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),
Expand Down
2 changes: 1 addition & 1 deletion datafusion/src/logical_plan/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we should keep a log entry / alias to log10 for postgres compatibility?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here the macro defs shall not allow dups

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely in favour of Postgres behaviour. 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #275

unary_scalar_expr!(Log2, log2);
unary_scalar_expr!(Log10, log10);
unary_scalar_expr!(Ln, ln);

// string functions
unary_scalar_expr!(Ascii, ascii);
Expand Down
9 changes: 7 additions & 2 deletions datafusion/src/physical_plan/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -633,6 +636,7 @@ pub fn return_type(
| BuiltinScalarFunction::Exp
| BuiltinScalarFunction::Floor
| BuiltinScalarFunction::Log
| BuiltinScalarFunction::Ln
| BuiltinScalarFunction::Log10
| BuiltinScalarFunction::Log2
| BuiltinScalarFunction::Round
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion datafusion/src/physical_plan/math_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);