Skip to content

Commit

Permalink
move functions.rs to sqllogictests (#6608)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangzhx authored Jun 9, 2023
1 parent eacbdd9 commit d9e91d1
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 145 deletions.
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 (
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

0 comments on commit d9e91d1

Please sign in to comment.