From 33b0fee5cda65b4c384ebd0da748c5c336b844ff Mon Sep 17 00:00:00 2001 From: Leonid Fedorov Date: Thu, 7 Mar 2024 12:52:56 +0000 Subject: [PATCH] tests and review fixes --- .drone.jsonnet | 14 +++++++------- .../basic/r/mcs228_regexp_operator.result | 5 +++++ .../basic/r/mcs244_regexp_instr_function.result | 5 ++++- .../basic/r/mcs245_regexp_replace_function.result | 5 ++++- .../basic/r/mcs246_regexp_substr_function.result | 5 ++++- .../basic/t/mcs228_regexp_operator.test | 2 +- .../basic/t/mcs244_regexp_instr_function.test | 1 - .../basic/t/mcs245_regexp_replace_function.test | 1 - .../basic/t/mcs246_regexp_substr_function.test | 1 - utils/funcexp/func_regexp.cpp | 15 ++++++++------- 10 files changed, 33 insertions(+), 21 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index fe49ad61a..05e62b3c3 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -125,13 +125,13 @@ local testRun(platform) = local testPreparation(platform) = local platform_map = { - 'centos:7': 'yum -y install epel-release && yum install -y git cppunit-devel cmake3 boost-devel snappy-devel', - 'rockylinux:8': rockylinux8_build_deps + ' && dnf install -y git lz4 cppunit-devel cmake3 boost-devel snappy-devel', - 'rockylinux:9': rockylinux9_build_deps + ' && dnf install -y git lz4 cppunit-devel cmake3 boost-devel snappy-devel', - 'debian:11': 'apt update && apt install --yes git libboost-all-dev libcppunit-dev libsnappy-dev cmake', - 'debian:12': 'apt update && apt install --yes git libboost-all-dev libcppunit-dev libsnappy-dev cmake', - 'ubuntu:20.04': 'apt update && apt install --yes git libboost-all-dev libcppunit-dev libsnappy-dev cmake', - 'ubuntu:22.04': 'apt update && apt install --yes git libboost-all-dev libcppunit-dev libsnappy-dev cmake', + 'centos:7': 'yum -y install epel-release && yum install -y git cppunit-devel cmake3 boost-devel snappy-devel pcre2-devel', + 'rockylinux:8': rockylinux8_build_deps + ' && dnf install -y git lz4 cppunit-devel cmake3 boost-devel snappy-devel pcre2-devel', + 'rockylinux:9': rockylinux9_build_deps + ' && dnf install -y git lz4 cppunit-devel cmake3 boost-devel snappy-devel pcre2-devel', + 'debian:11': 'apt update && apt install --yes git libboost-all-dev libcppunit-dev libsnappy-dev cmake libpcre2-dev', + 'debian:12': 'apt update && apt install --yes git libboost-all-dev libcppunit-dev libsnappy-dev cmake libpcre2-dev', + 'ubuntu:20.04': 'apt update && apt install --yes git libboost-all-dev libcppunit-dev libsnappy-dev cmake libpcre2-dev', + 'ubuntu:22.04': 'apt update && apt install --yes git libboost-all-dev libcppunit-dev libsnappy-dev cmake libpcre2-dev', }; platform_map[platform]; diff --git a/mysql-test/columnstore/basic/r/mcs228_regexp_operator.result b/mysql-test/columnstore/basic/r/mcs228_regexp_operator.result index a130de285..f3e5a7d78 100644 --- a/mysql-test/columnstore/basic/r/mcs228_regexp_operator.result +++ b/mysql-test/columnstore/basic/r/mcs228_regexp_operator.result @@ -412,6 +412,11 @@ t1_TEXT REGEXP_REPLACE(t1_TEXT, 'o?o', 'KittyCat') ooooo KittyCatKittyCatKittyCat ppppp ppppp qqqqq qqqqq +SELECT t1_TEXT, REGEXP_REPLACE(t1_TEXT, 'q', 'KittyCat') FROM t1 ORDER BY 1; +t1_TEXT REGEXP_REPLACE(t1_TEXT, 'q', 'KittyCat') +ooooo ooooo +ppppp ppppp +qqqqq KittyCatKittyCatKittyCatKittyCatKittyCat SELECT t1_DATE, t1_DATE REGEXP '(1997)+' FROM t1 ORDER BY 1; t1_DATE t1_DATE REGEXP '(1997)+' 1997-12-12 1 diff --git a/mysql-test/columnstore/basic/r/mcs244_regexp_instr_function.result b/mysql-test/columnstore/basic/r/mcs244_regexp_instr_function.result index 5f48b7d13..3658dfeed 100644 --- a/mysql-test/columnstore/basic/r/mcs244_regexp_instr_function.result +++ b/mysql-test/columnstore/basic/r/mcs244_regexp_instr_function.result @@ -13,5 +13,8 @@ INSERT INTO t1 VALUES(103, 1234.5699, repeat('o', 5), '1997-12-12', '22:12:02'); INSERT INTO t1 VALUES(-7299, 111.99, repeat('p', 5), '2001-1-1', '23:59:59'); INSERT INTO t1 VALUES(9913, 98765.4321, repeat('q', 5), '09-12-11', '01:08:59'); SELECT t1_TEXT, REGEXP_INSTR(t1_TEXT, 'o') FROM t1 ORDER BY 1; -ERROR 42000: The storage engine for the table doesn't support MCS-1001: Function 'regexp_instr' isn't supported. +t1_TEXT REGEXP_INSTR(t1_TEXT, 'o') +ooooo 1 +ppppp 0 +qqqqq 0 DROP DATABASE mcs244_db; diff --git a/mysql-test/columnstore/basic/r/mcs245_regexp_replace_function.result b/mysql-test/columnstore/basic/r/mcs245_regexp_replace_function.result index d1b65185a..dba276857 100644 --- a/mysql-test/columnstore/basic/r/mcs245_regexp_replace_function.result +++ b/mysql-test/columnstore/basic/r/mcs245_regexp_replace_function.result @@ -13,5 +13,8 @@ INSERT INTO t1 VALUES(103, 1234.5699, repeat('o', 5), '1997-12-12', '22:12:02'); INSERT INTO t1 VALUES(-7299, 111.99, repeat('p', 5), '2001-1-1', '23:59:59'); INSERT INTO t1 VALUES(9913, 98765.4321, repeat('q', 5), '09-12-11', '01:08:59'); SELECT REGEXP_REPLACE(t1_TEXT, 'o', 'X') FROM t1 ORDER BY 1; -ERROR 42000: The storage engine for the table doesn't support MCS-1001: Function 'regexp_replace' isn't supported. +REGEXP_REPLACE(t1_TEXT, 'o', 'X') +ppppp +qqqqq +XXXXX DROP DATABASE mcs245_db; diff --git a/mysql-test/columnstore/basic/r/mcs246_regexp_substr_function.result b/mysql-test/columnstore/basic/r/mcs246_regexp_substr_function.result index 965f01577..2d44aec16 100644 --- a/mysql-test/columnstore/basic/r/mcs246_regexp_substr_function.result +++ b/mysql-test/columnstore/basic/r/mcs246_regexp_substr_function.result @@ -13,5 +13,8 @@ INSERT INTO t1 VALUES(103, 1234.5699, repeat('o', 5), '1997-12-12', '22:12:02'); INSERT INTO t1 VALUES(-7299, 111.99, repeat('p', 5), '2001-1-1', '23:59:59'); INSERT INTO t1 VALUES(9913, 98765.4321, repeat('q', 5), '09-12-11', '01:08:59'); SELECT REGEXP_SUBSTR(t1_TEXT, '[a-z]+') FROM t1 ORDER BY 1; -ERROR 42000: The storage engine for the table doesn't support MCS-1001: Function 'regexp_substr' isn't supported. +REGEXP_SUBSTR(t1_TEXT, '[a-z]+') +ooooo +ppppp +qqqqq DROP DATABASE mcs246_db; diff --git a/mysql-test/columnstore/basic/t/mcs228_regexp_operator.test b/mysql-test/columnstore/basic/t/mcs228_regexp_operator.test index 692f196f8..88e6ffd08 100644 --- a/mysql-test/columnstore/basic/t/mcs228_regexp_operator.test +++ b/mysql-test/columnstore/basic/t/mcs228_regexp_operator.test @@ -115,7 +115,7 @@ SELECT t1_TEXT, REGEXP_REPLACE(t1_TEXT, '(qqqqq)+', 'KittyCat') FROM t1 ORDER BY SELECT t1_TEXT, REGEXP_REPLACE(t1_TEXT, 'p*', 'KittyCat') FROM t1 ORDER BY 1; SELECT t1_TEXT, REGEXP_REPLACE(t1_TEXT, 'qq+q', 'KittyCat') FROM t1 ORDER BY 1; SELECT t1_TEXT, REGEXP_REPLACE(t1_TEXT, 'o?o', 'KittyCat') FROM t1 ORDER BY 1; - +SELECT t1_TEXT, REGEXP_REPLACE(t1_TEXT, 'q', 'KittyCat') FROM t1 ORDER BY 1; SELECT t1_DATE, t1_DATE REGEXP '(1997)+' FROM t1 ORDER BY 1; SELECT t1_DATE, t1_DATE REGEXP '01$' FROM t1 ORDER BY 1; diff --git a/mysql-test/columnstore/basic/t/mcs244_regexp_instr_function.test b/mysql-test/columnstore/basic/t/mcs244_regexp_instr_function.test index fca3ddecb..2c0e35d07 100644 --- a/mysql-test/columnstore/basic/t/mcs244_regexp_instr_function.test +++ b/mysql-test/columnstore/basic/t/mcs244_regexp_instr_function.test @@ -23,7 +23,6 @@ INSERT INTO t1 VALUES(103, 1234.5699, repeat('o', 5), '1997-12-12', '22:12:02'); INSERT INTO t1 VALUES(-7299, 111.99, repeat('p', 5), '2001-1-1', '23:59:59'); INSERT INTO t1 VALUES(9913, 98765.4321, repeat('q', 5), '09-12-11', '01:08:59'); ---error ER_CHECK_NOT_IMPLEMENTED SELECT t1_TEXT, REGEXP_INSTR(t1_TEXT, 'o') FROM t1 ORDER BY 1; # Clean UP diff --git a/mysql-test/columnstore/basic/t/mcs245_regexp_replace_function.test b/mysql-test/columnstore/basic/t/mcs245_regexp_replace_function.test index ed27b9365..d6f22fdef 100644 --- a/mysql-test/columnstore/basic/t/mcs245_regexp_replace_function.test +++ b/mysql-test/columnstore/basic/t/mcs245_regexp_replace_function.test @@ -23,7 +23,6 @@ INSERT INTO t1 VALUES(103, 1234.5699, repeat('o', 5), '1997-12-12', '22:12:02'); INSERT INTO t1 VALUES(-7299, 111.99, repeat('p', 5), '2001-1-1', '23:59:59'); INSERT INTO t1 VALUES(9913, 98765.4321, repeat('q', 5), '09-12-11', '01:08:59'); ---error ER_CHECK_NOT_IMPLEMENTED SELECT REGEXP_REPLACE(t1_TEXT, 'o', 'X') FROM t1 ORDER BY 1; # Clean UP diff --git a/mysql-test/columnstore/basic/t/mcs246_regexp_substr_function.test b/mysql-test/columnstore/basic/t/mcs246_regexp_substr_function.test index 29e8eba5b..cadab930d 100644 --- a/mysql-test/columnstore/basic/t/mcs246_regexp_substr_function.test +++ b/mysql-test/columnstore/basic/t/mcs246_regexp_substr_function.test @@ -23,7 +23,6 @@ INSERT INTO t1 VALUES(103, 1234.5699, repeat('o', 5), '1997-12-12', '22:12:02'); INSERT INTO t1 VALUES(-7299, 111.99, repeat('p', 5), '2001-1-1', '23:59:59'); INSERT INTO t1 VALUES(9913, 98765.4321, repeat('q', 5), '09-12-11', '01:08:59'); ---error ER_CHECK_NOT_IMPLEMENTED SELECT REGEXP_SUBSTR(t1_TEXT, '[a-z]+') FROM t1 ORDER BY 1; # Clean UP diff --git a/utils/funcexp/func_regexp.cpp b/utils/funcexp/func_regexp.cpp index 25f405ec8..ad8332371 100644 --- a/utils/funcexp/func_regexp.cpp +++ b/utils/funcexp/func_regexp.cpp @@ -259,10 +259,11 @@ std::string Func_regexp_replace::getStrVal(rowgroup::Row& row, FunctionParm& fp, execplan::CalpontSystemCatalog::ColType& ct) { + RegExpParams param = getEpressionAndPattern(row, fp, isNull, ct, ct.getTimeZone()); + if (isNull) return std::string{}; - RegExpParams param = getEpressionAndPattern(row, fp, isNull, ct, ct.getTimeZone()); const auto& replace_with = fp[2]->data()->getStrVal(row, isNull); if (replace_with.isNull()) @@ -280,11 +281,11 @@ std::string Func_regexp_substr::getStrVal(rowgroup::Row& row, FunctionParm& fp, execplan::CalpontSystemCatalog::ColType& ct) { + RegExpParams param = getEpressionAndPattern(row, fp, isNull, ct, ct.getTimeZone()); + if (isNull) return std::string{}; - RegExpParams param = getEpressionAndPattern(row, fp, isNull, ct, ct.getTimeZone()); - jp::Regex re(param.pattern); jp::RegexMatch rm(&re); jp::VecNum vec_num; @@ -305,11 +306,11 @@ std::string Func_regexp_instr::getStrVal(rowgroup::Row& row, FunctionParm& fp, b execplan::CalpontSystemCatalog::ColType& ct) { + RegExpParams param = getEpressionAndPattern(row, fp, isNull, ct, ct.getTimeZone()); + if (isNull) return std::string{}; - RegExpParams param = getEpressionAndPattern(row, fp, isNull, ct, ct.getTimeZone()); - jp::Regex re(param.pattern); jp::RegexMatch rm(&re); jpcre2::VecOff vec_soff; @@ -328,11 +329,11 @@ std::string Func_regexp_instr::getStrVal(rowgroup::Row& row, FunctionParm& fp, b bool Func_regexp::getBoolVal(rowgroup::Row& row, FunctionParm& fp, bool& isNull, CalpontSystemCatalog::ColType& ct) { + RegExpParams param = getEpressionAndPattern(row, fp, isNull, ct, ct.getTimeZone()); + if (isNull) return false; - RegExpParams param = getEpressionAndPattern(row, fp, isNull, ct, ct.getTimeZone()); - jp::Regex re(param.pattern); return re.match(param.expression); }