mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-04-20 09:07:44 +03:00
This patch improves handling of NULLs in textual fields in ColumnStore. Previously empty strings were considered NULLs and it could be a problem if data scheme allows for empty strings. It was also one of major reasons of behavior difference between ColumnStore and other engines in MariaDB family. Also, this patch fixes some other bugs and incorrect behavior, for example, incorrect comparison for "column <= ''" which evaluates to constant True for all purposes before this patch.
72 lines
2.6 KiB
Plaintext
72 lines
2.6 KiB
Plaintext
#
|
|
# Test Aggregate Functions
|
|
# Author: Bharath, bharath.bokka@mariadb.com
|
|
#
|
|
-- source include/have_innodb.inc
|
|
-- source ../include/have_columnstore.inc
|
|
|
|
if (!$MASTER_MYPORT)
|
|
{
|
|
# Running with --extern
|
|
let $MASTER_MYPORT=`SELECT @@port`;
|
|
}
|
|
|
|
--disable_warnings
|
|
DROP DATABASE IF EXISTS mcs90_db;
|
|
--enable_warnings
|
|
|
|
CREATE DATABASE mcs90_db;
|
|
USE mcs90_db;
|
|
|
|
#
|
|
# Enable cross engine join
|
|
# Configure user and password in Columnstore.xml file
|
|
#
|
|
--exec $MCS_MCSSETCONFIG CrossEngineSupport User 'cejuser'
|
|
--exec $MCS_MCSSETCONFIG CrossEngineSupport Password 'Vagrant1|0000001'
|
|
--exec $MCS_MCSSETCONFIG CrossEngineSupport Port $MASTER_MYPORT
|
|
|
|
#
|
|
# Create corresponding in the server
|
|
#
|
|
--disable_warnings
|
|
CREATE USER IF NOT EXISTS 'cejuser'@'localhost' IDENTIFIED BY 'Vagrant1|0000001';
|
|
--enable_warnings
|
|
GRANT ALL PRIVILEGES ON *.* TO 'cejuser'@'localhost';
|
|
FLUSH PRIVILEGES;
|
|
|
|
CREATE TABLE t1 (a INT, b CHAR(5))ENGINE=Columnstore;
|
|
INSERT INTO t1 VALUES (NULL, NULL),(1, 'aaa'),(2, 'aaa'),(3, 'ccc'),(4, 'ddd'),(5, 'aaa'),(6, 'ddd'),(7, 'eee');
|
|
|
|
SELECT * FROM t1;
|
|
SELECT b, SUM(a) FROM t1 GROUP BY b ORDER BY b;
|
|
SELECT SUM(a) FROM t1 WHERE b LIKE '%a%';
|
|
SELECT a, AVG(a) FROM t1 GROUP BY a ORDER BY a;
|
|
SELECT b, AVG(a) FROM t1 WHERE b LIKE '%a%' GROUP BY b;
|
|
SELECT COUNT(*) FROM t1;
|
|
SELECT b, COUNT(*) FROM t1 GROUP BY b ORDER BY 1;
|
|
SELECT t1.b, COUNT(*) FROM t1 JOIN t1 AS t ON t1.a = t.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT MAX(a) FROM t1;
|
|
SELECT MIN(a) FROM t1;
|
|
|
|
# cross engine
|
|
CREATE TABLE t2 (a INT, b CHAR(5))ENGINE=Innodb;
|
|
CREATE TABLE t3 (a INT, b CHAR(5))ENGINE=Myisam;
|
|
INSERT INTO t2 VALUES (NULL, ''),(1, 'eee'),(3, 'ccc'),(5, 'jjj'),(6, ''),(7, 'ccc'),(9, 'eee'),(11, 'jjj');
|
|
INSERT INTO t3 VALUES (NULL, ''),(1, 'eee'),(3, 'ccc'),(5, 'jjj'),(6, ''),(7, 'ccc'),(9, 'eee'),(11, 'jjj');
|
|
|
|
SELECT t1.b, COUNT(*) FROM t1 JOIN t2 ON t1.a = t2.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT t1.b, SUM(t1.a) FROM t1 JOIN t2 ON t1.a = t2.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT t1.b, AVG(t1.a) FROM t1 JOIN t2 ON t1.a = t2.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT t1.b, MAX(t1.a) FROM t1 JOIN t2 ON t1.a = t2.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT t1.b, MIN(t1.a) FROM t1 JOIN t2 ON t1.a = t2.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT t1.b, COUNT(*) FROM t1 JOIN t3 ON t1.a = t3.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT t1.b, SUM(t1.a) FROM t1 JOIN t3 ON t1.a = t3.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT t1.b, AVG(t1.a) FROM t1 JOIN t3 ON t1.a = t3.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT t1.b, MAX(t1.a) FROM t1 JOIN t3 ON t1.a = t3.a GROUP BY t1.b ORDER BY 1;
|
|
SELECT t1.b, MIN(t1.a) FROM t1 JOIN t3 ON t1.a = t3.a GROUP BY t1.b ORDER BY 1;
|
|
|
|
# Clean UP
|
|
DROP USER 'cejuser'@'localhost';
|
|
DROP DATABASE mcs90_db;
|