Skip to content

Port remaining tests in functions.rs to sqllogictest #6608

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

Merged
merged 1 commit into from
Jun 9, 2023
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
143 changes: 0 additions & 143 deletions datafusion/core/tests/sql/functions.rs

This file was deleted.

1 change: 0 additions & 1 deletion datafusion/core/tests/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ pub mod arrow_files;
pub mod create_drop;
pub mod explain_analyze;
pub mod expr;
pub mod functions;
pub mod group_by;
pub mod joins;
pub mod limit;
Expand Down
88 changes: 87 additions & 1 deletion datafusion/core/tests/sqllogictests/test_files/functions.slt
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,90 @@ SELECT struct(c1,c2,c3,c4,a,b) from simple_struct_test
{c0: 1, c1: 1, c2: 3.1, c3: 3.14, c4: str, c5: text}

statement ok
drop table simple_struct_test
drop table simple_struct_test

# create aggregate_test_100 table for functions test
statement ok
CREATE EXTERNAL TABLE aggregate_test_100 (
c1 VARCHAR NOT NULL,
c2 TINYINT NOT NULL,
c3 SMALLINT NOT NULL,
c4 SMALLINT,
c5 INT,
c6 BIGINT NOT NULL,
c7 SMALLINT NOT NULL,
c8 INT NOT NULL,
c9 BIGINT UNSIGNED NOT NULL,
c10 VARCHAR NOT NULL,
c11 FLOAT NOT NULL,
c12 DOUBLE NOT NULL,
c13 VARCHAR NOT NULL
)
STORED AS CSV
WITH HEADER ROW
LOCATION '../../testing/data/csv/aggregate_test_100.csv'


# sqrt_f32_vs_f64
query R
SELECT avg(sqrt(c11)) FROM aggregate_test_100
----
0.658440848589

query R
SELECT avg(CAST(sqrt(c11) AS double)) FROM aggregate_test_100
----
0.658440848589

query R
SELECT avg(sqrt(CAST(c11 AS double))) FROM aggregate_test_100
----
0.658440848342

statement ok
drop table aggregate_test_100


# case_sensitive_identifiers_functions
statement ok
create table t as values (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think using 2 is a better value than 1 👍

arrow_cast(2, 'Int8'),
arrow_cast(2, 'Int16'),
arrow_cast(2, 'Int32'),
arrow_cast(2, 'Int64'),
arrow_cast(2, 'UInt8'),
arrow_cast(2, 'UInt16'),
arrow_cast(2, 'UInt32'),
arrow_cast(2, 'UInt64'),
arrow_cast(2, 'Float32'),
arrow_cast(2, 'Float64')
)
;

query R
SELECT sqrt(column1) FROM t
----
1.414213562373

query R
SELECT SQRT(column1) FROM t
----
1.414213562373

statement error Error during planning: Invalid function 'SQRT'
SELECT "SQRT"(column1) FROM t

query R
SELECT "sqrt"(column1) FROM t
----
1.414213562373

# case_builtin_math_expression
query RRRRRRRRRR
SELECT sqrt(column1),sqrt(column2),sqrt(column3),sqrt(column4),sqrt(column5),sqrt(column6),sqrt(column7),sqrt(column8),sqrt(column9),sqrt(column10) FROM t
----
1.414213562373 1.414213562373 1.414213562373 1.414213562373 1.414213562373 1.414213562373 1.414213562373 1.414213562373 1.4142135 1.414213562373

statement ok
drop table t