-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(mtr):add xx_function.test(#497)
- Loading branch information
1 parent
bf6f4e3
commit bfb68a0
Showing
16 changed files
with
460 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Test AVG as distributed aggregate function | ||
# Author: syw | ||
# | ||
DROP DATABASE IF EXISTS mcs188_db; | ||
CREATE DATABASE mcs188_db; | ||
USE mcs188_db; | ||
CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; | ||
INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); | ||
SELECT AVG(DISTINCT a) FROM t1; | ||
AVG(DISTINCT a) | ||
4.1667 | ||
SELECT AVG(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; | ||
AVG(DISTINCT a) | ||
2.6667 | ||
SELECT b, AVG(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; | ||
b AVG(DISTINCT a) | ||
eee 7.0000 | ||
ddd 5.0000 | ||
ccc 1.0000 | ||
aaa 2.6667 | ||
NULL | ||
SELECT AVG(a) FROM t1; | ||
AVG(a) | ||
3.7143 | ||
DROP DATABASE mcs188_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# | ||
# Test DAYNAME function | ||
# Author: syw | ||
# | ||
DROP DATABASE IF EXISTS mcs185_db; | ||
CREATE DATABASE mcs185_db; | ||
USE mcs185_db; | ||
CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; | ||
INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`a` date DEFAULT NULL, | ||
`b` datetime DEFAULT NULL | ||
) ENGINE=TIANMU DEFAULT CHARSET=latin1 | ||
SELECT DAYNAME('1212-12-12 11:11:11'); | ||
DAYNAME('1212-12-12 11:11:11') | ||
Wednesday | ||
SELECT DAYNAME('2020-12-22'); | ||
DAYNAME('2020-12-22') | ||
Tuesday | ||
SELECT a, DAYNAME(a) FROM t1 ORDER BY 1; | ||
a DAYNAME(a) | ||
1212-12-12 Wednesday | ||
1990-10-10 Wednesday | ||
3333-03-03 Tuesday | ||
SELECT b, DAYNAME(b) FROM t1 ORDER BY 1; | ||
b DAYNAME(b) | ||
1212-12-11 11:11:11 Tuesday | ||
1990-10-10 00:00:00 Wednesday | ||
3333-03-04 03:33:33 Wednesday | ||
DROP DATABASE mcs185_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# | ||
# Test DAYOFMONTH function | ||
# Author: syw | ||
# | ||
DROP DATABASE IF EXISTS mcs187_db; | ||
CREATE DATABASE mcs187_db; | ||
USE mcs187_db; | ||
CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; | ||
INSERT INTO t1 VALUES ('1990-10-10', '1990-01-01 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`a` date DEFAULT NULL, | ||
`b` datetime DEFAULT NULL | ||
) ENGINE=TIANMU DEFAULT CHARSET=latin1 | ||
SELECT DAYOFMONTH('1212-12-12 11:11:11'); | ||
DAYOFMONTH('1212-12-12 11:11:11') | ||
12 | ||
SELECT DAYOFMONTH('2020-12-22'); | ||
DAYOFMONTH('2020-12-22') | ||
22 | ||
SELECT a, DAYOFMONTH(a) FROM t1 ORDER BY 1; | ||
a DAYOFMONTH(a) | ||
1212-12-12 12 | ||
1990-10-10 10 | ||
3333-03-03 3 | ||
SELECT b, DAYOFMONTH(b) FROM t1 ORDER BY 1; | ||
b DAYOFMONTH(b) | ||
1212-12-11 11:11:11 11 | ||
1990-01-01 00:00:00 1 | ||
3333-03-04 03:33:33 4 | ||
DROP DATABASE mcs187_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# | ||
# Test DAYOFYEAR function | ||
# Author: syw | ||
# | ||
DROP DATABASE IF EXISTS mcs186_db; | ||
CREATE DATABASE mcs186_db; | ||
USE mcs186_db; | ||
CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; | ||
INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); | ||
SHOW CREATE TABLE t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`a` date DEFAULT NULL, | ||
`b` datetime DEFAULT NULL | ||
) ENGINE=TIANMU DEFAULT CHARSET=latin1 | ||
SELECT DAYOFYEAR('1212-12-12 11:11:11'); | ||
DAYOFYEAR('1212-12-12 11:11:11') | ||
347 | ||
SELECT DAYOFYEAR('2020-12-22'); | ||
DAYOFYEAR('2020-12-22') | ||
357 | ||
SELECT a, DAYOFYEAR(a) FROM t1 ORDER BY 1; | ||
a DAYOFYEAR(a) | ||
1212-12-12 347 | ||
1990-10-10 283 | ||
3333-03-03 62 | ||
SELECT b, DAYOFYEAR(b) FROM t1 ORDER BY 1; | ||
b DAYOFYEAR(b) | ||
1212-12-11 11:11:11 346 | ||
1990-10-10 00:00:00 283 | ||
3333-03-04 03:33:33 63 | ||
DROP DATABASE mcs186_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Test MAX as distributed aggregate function | ||
# Author: syw | ||
# | ||
DROP DATABASE IF EXISTS mcs190_db; | ||
CREATE DATABASE mcs190_db; | ||
USE mcs190_db; | ||
CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; | ||
INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); | ||
SELECT MAX(DISTINCT a) FROM t1; | ||
MAX(DISTINCT a) | ||
7 | ||
SELECT MAX(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; | ||
MAX(DISTINCT a) | ||
5 | ||
SELECT b, MAX(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; | ||
b MAX(DISTINCT a) | ||
eee 7 | ||
ddd 6 | ||
ccc 1 | ||
aaa 5 | ||
NULL | ||
SELECT MAX(a) FROM t1; | ||
MAX(a) | ||
7 | ||
DROP DATABASE mcs190_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# Test MD5() function | ||
# Author: syw | ||
# | ||
DROP DATABASE IF EXISTS mcs218_db; | ||
CREATE DATABASE mcs218_db; | ||
USE mcs218_db; | ||
CREATE TABLE t1 | ||
( | ||
t1_BIGINT BIGINT, | ||
t1_DOUBLE DOUBLE, | ||
t1_FLOAT FLOAT, | ||
t1_BLOB BLOB, | ||
t1_TEXT TEXT, | ||
t1_CHAR_1 CHAR(1), | ||
t1_DATETIME DATETIME | ||
)ENGINE=tianmu; | ||
INSERT INTO t1 VALUES(NULL, NULL, NULL, '', '', '', '1990-10-01'); | ||
INSERT INTO t1 VALUES(203685477580676, -3.797693231E+108, -7.402866E+18, repeat('b',10), repeat('b',10), 'b', '2387-11-08 11:22:30.123'); | ||
SELECT t1_BIGINT, MD5(t1_BIGINT) FROM t1 ORDER BY t1_BIGINT; | ||
t1_BIGINT MD5(t1_BIGINT) | ||
NULL NULL | ||
203685477580676 9e05a00575dbbdb0e9c03d479cea5eb9 | ||
SELECT t1_DOUBLE, MD5(t1_DOUBLE) FROM t1 ORDER BY t1_DOUBLE; | ||
t1_DOUBLE MD5(t1_DOUBLE) | ||
NULL NULL | ||
-3.797693231e108 bba02430bfe020a8d8ddffaff6b04004 | ||
SELECT t1_FLOAT, MD5(t1_FLOAT) FROM t1 ORDER BY t1_FLOAT; | ||
t1_FLOAT MD5(t1_FLOAT) | ||
NULL NULL | ||
-7.40287e18 c779664c54f557edbb5360386ff7d8b4 | ||
SELECT t1_TEXT, MD5(t1_TEXT) FROM t1 ORDER BY t1_TEXT; | ||
t1_TEXT MD5(t1_TEXT) | ||
d41d8cd98f00b204e9800998ecf8427e | ||
bbbbbbbbbb 82136b4240d6ce4ea7d03e51469a393b | ||
SELECT t1_CHAR_1, MD5(t1_CHAR_1) FROM t1 ORDER BY t1_CHAR_1; | ||
t1_CHAR_1 MD5(t1_CHAR_1) | ||
d41d8cd98f00b204e9800998ecf8427e | ||
b 92eb5ffee6ae2fec3ad71c777531578f | ||
SELECT t1_DATETIME, MD5(t1_DATETIME) FROM t1 ORDER BY t1_DATETIME; | ||
t1_DATETIME MD5(t1_DATETIME) | ||
1990-10-01 00:00:00 626bab9c604a72a1959951119b91c8b2 | ||
2387-11-08 11:22:30 9cf01b3f830ff29aa3f394fd54ea5a23 | ||
SELECT t1_DATETIME FROM t1 WHERE MD5(t1_DATETIME) <> 0 ORDER BY t1_DATETIME; | ||
t1_DATETIME | ||
1990-10-01 00:00:00 | ||
2387-11-08 11:22:30 | ||
DROP DATABASE mcs218_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Test MIN as distributed aggregate function | ||
# Author: syw | ||
# | ||
DROP DATABASE IF EXISTS mcs191_db; | ||
CREATE DATABASE mcs191_db; | ||
USE mcs191_db; | ||
CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; | ||
INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); | ||
SELECT MIN(DISTINCT a) FROM t1; | ||
MIN(DISTINCT a) | ||
1 | ||
SELECT MIN(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; | ||
MIN(DISTINCT a) | ||
1 | ||
SELECT b, MIN(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; | ||
b MIN(DISTINCT a) | ||
eee 7 | ||
ddd 4 | ||
ccc 1 | ||
aaa 1 | ||
NULL | ||
SELECT MIN(a) FROM t1; | ||
MIN(a) | ||
1 | ||
DROP DATABASE mcs191_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Test SUM as distributed aggregate function | ||
# Author: syw | ||
# | ||
DROP DATABASE IF EXISTS mcs189_db; | ||
CREATE DATABASE mcs189_db; | ||
USE mcs189_db; | ||
CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; | ||
INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); | ||
SELECT SUM(DISTINCT a) FROM t1; | ||
SUM(DISTINCT a) | ||
25 | ||
SELECT SUM(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; | ||
SUM(DISTINCT a) | ||
8 | ||
SELECT b, SUM(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; | ||
b SUM(DISTINCT a) | ||
eee 7 | ||
ddd 10 | ||
ccc 1 | ||
aaa 8 | ||
NULL | ||
SELECT SUM(a) FROM t1; | ||
SUM(a) | ||
26 | ||
DROP DATABASE mcs189_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--echo # | ||
--echo # Test AVG as distributed aggregate function | ||
--echo # Author: syw | ||
--echo # | ||
|
||
--source include/have_tianmu.inc | ||
|
||
--disable_warnings | ||
DROP DATABASE IF EXISTS mcs188_db; | ||
--enable_warnings | ||
|
||
CREATE DATABASE mcs188_db; | ||
USE mcs188_db; | ||
|
||
CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; | ||
INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); | ||
|
||
SELECT AVG(DISTINCT a) FROM t1; | ||
SELECT AVG(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; | ||
SELECT b, AVG(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; | ||
SELECT AVG(a) FROM t1; | ||
|
||
# Clean UP | ||
DROP DATABASE mcs188_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--echo # | ||
--echo # Test DAYNAME function | ||
--echo # Author: syw | ||
--echo # | ||
|
||
--source include/have_tianmu.inc | ||
|
||
--disable_warnings | ||
DROP DATABASE IF EXISTS mcs185_db; | ||
--enable_warnings | ||
|
||
CREATE DATABASE mcs185_db; | ||
USE mcs185_db; | ||
|
||
CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; | ||
INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); | ||
SHOW CREATE TABLE t1; | ||
|
||
SELECT DAYNAME('1212-12-12 11:11:11'); | ||
SELECT DAYNAME('2020-12-22'); | ||
|
||
SELECT a, DAYNAME(a) FROM t1 ORDER BY 1; | ||
SELECT b, DAYNAME(b) FROM t1 ORDER BY 1; | ||
|
||
# Clean UP | ||
DROP DATABASE mcs185_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--echo # | ||
--echo # Test DAYOFMONTH function | ||
--echo # Author: syw | ||
--echo # | ||
|
||
--source include/have_tianmu.inc | ||
|
||
--disable_warnings | ||
DROP DATABASE IF EXISTS mcs187_db; | ||
--enable_warnings | ||
|
||
CREATE DATABASE mcs187_db; | ||
USE mcs187_db; | ||
|
||
CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; | ||
INSERT INTO t1 VALUES ('1990-10-10', '1990-01-01 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); | ||
SHOW CREATE TABLE t1; | ||
|
||
SELECT DAYOFMONTH('1212-12-12 11:11:11'); | ||
SELECT DAYOFMONTH('2020-12-22'); | ||
|
||
SELECT a, DAYOFMONTH(a) FROM t1 ORDER BY 1; | ||
SELECT b, DAYOFMONTH(b) FROM t1 ORDER BY 1; | ||
|
||
# Clean UP | ||
DROP DATABASE mcs187_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--echo # | ||
--echo # Test DAYOFYEAR function | ||
--echo # Author: syw | ||
--echo # | ||
|
||
--source include/have_tianmu.inc | ||
|
||
--disable_warnings | ||
DROP DATABASE IF EXISTS mcs186_db; | ||
--enable_warnings | ||
|
||
CREATE DATABASE mcs186_db; | ||
USE mcs186_db; | ||
|
||
CREATE TABLE t1 (a DATE, b DATETIME)engine=tianmu; | ||
INSERT INTO t1 VALUES ('1990-10-10', '1990-10-10 0:0:0'), ('1212-12-12', '1212-12-11 11:11:11'), ('3333-03-03', '3333-3-4 3:33:33'); | ||
SHOW CREATE TABLE t1; | ||
|
||
SELECT DAYOFYEAR('1212-12-12 11:11:11'); | ||
SELECT DAYOFYEAR('2020-12-22'); | ||
|
||
SELECT a, DAYOFYEAR(a) FROM t1 ORDER BY 1; | ||
SELECT b, DAYOFYEAR(b) FROM t1 ORDER BY 1; | ||
|
||
# Clean UP | ||
DROP DATABASE mcs186_db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--echo # | ||
--echo # Test MAX as distributed aggregate function | ||
--echo # Author: syw | ||
--echo # | ||
|
||
--source include/have_tianmu.inc | ||
|
||
--disable_warnings | ||
DROP DATABASE IF EXISTS mcs190_db; | ||
--enable_warnings | ||
|
||
CREATE DATABASE mcs190_db; | ||
USE mcs190_db; | ||
|
||
CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=tianmu; | ||
INSERT INTO t1 VALUES (NULL, ''),(1, 'aaa'),(2, 'aaa'),(1, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee'); | ||
|
||
SELECT MAX(DISTINCT a) FROM t1; | ||
SELECT MAX(DISTINCT a) FROM t1 GROUP BY b HAVING b = 'aaa'; | ||
SELECT b, MAX(DISTINCT a) FROM t1 GROUP BY b ORDER BY b DESC; | ||
SELECT MAX(a) FROM t1; | ||
|
||
# Clean UP | ||
DROP DATABASE mcs190_db; |
Oops, something went wrong.