Skip to content
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
3 changes: 0 additions & 3 deletions datafusion/common/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,6 @@ impl ScalarValue {

/// Create an one value in the given type.
pub fn new_one(datatype: &DataType) -> Result<ScalarValue> {
assert!(datatype.is_primitive());
Copy link
Contributor

Choose a reason for hiding this comment

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

removing the assert (as any unhandled type will cause a runtime error) makes a lot of sense to me.

Ok(match datatype {
DataType::Int8 => ScalarValue::Int8(Some(1)),
DataType::Int16 => ScalarValue::Int16(Some(1)),
Expand All @@ -1086,7 +1085,6 @@ impl ScalarValue {

/// Create a negative one value in the given type.
pub fn new_negative_one(datatype: &DataType) -> Result<ScalarValue> {
assert!(datatype.is_primitive());
Ok(match datatype {
DataType::Int8 | DataType::UInt8 => ScalarValue::Int8(Some(-1)),
DataType::Int16 | DataType::UInt16 => ScalarValue::Int16(Some(-1)),
Expand All @@ -1104,7 +1102,6 @@ impl ScalarValue {
}

pub fn new_ten(datatype: &DataType) -> Result<ScalarValue> {
assert!(datatype.is_primitive());
Ok(match datatype {
DataType::Int8 => ScalarValue::Int8(Some(10)),
DataType::Int16 => ScalarValue::Int16(Some(10)),
Expand Down
34 changes: 34 additions & 0 deletions datafusion/sqllogictest/test_files/scalar.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1982,3 +1982,37 @@ query I
select strpos('joséésoj', arrow_cast(null, 'Utf8'));
----
NULL

statement ok
CREATE TABLE t1 (v1 int) AS VALUES (1), (2), (3);

query I
SELECT * FROM t1 ORDER BY ACOS(SIN(v1));
----
2
1
3

query I
SELECT * FROM t1 ORDER BY ACOSH(SIN(v1));
----
1
2
3

query I
SELECT * FROM t1 ORDER BY ASIN(SIN(v1));
----
3
1
2

query I
SELECT * FROM t1 ORDER BY ATANH(SIN(v1));
----
3
1
2

statement ok
drop table t1;