You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-11-02 06:13:16 +03:00
fix(funcexp): MCOL-4623 Add support for additional types to SEC_TO_TIME() (#3731)
This commit is contained in:
34
mysql-test/columnstore/bugfixes/mcol_4623.result
Normal file
34
mysql-test/columnstore/bugfixes/mcol_4623.result
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
DROP DATABASE IF EXISTS mcol_4623;
|
||||||
|
CREATE DATABASE mcol_4623;
|
||||||
|
USE mcol_4623;
|
||||||
|
CREATE TABLE t1 (a DOUBLE UNSIGNED) Engine=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES (1000);
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
SEC_TO_TIME(a)
|
||||||
|
00:16:40.000000
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (a TIME) ENGINE=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES ('17:31:27');
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
SEC_TO_TIME(a)
|
||||||
|
17:31:27
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (a DATE) ENGINE=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES ('2023-07-23');
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
SEC_TO_TIME(a)
|
||||||
|
838:59:59
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (a DATETIME) ENGINE=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES ('2009-03-17 14:30:45');
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
SEC_TO_TIME(a)
|
||||||
|
838:59:59
|
||||||
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (a TIMESTAMP) ENGINE=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES ('2017-01-01 04:30:45');
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
SEC_TO_TIME(a)
|
||||||
|
838:59:59
|
||||||
|
DROP TABLE t1;
|
||||||
|
DROP DATABASE mcol_4623;
|
||||||
45
mysql-test/columnstore/bugfixes/mcol_4623.test
Normal file
45
mysql-test/columnstore/bugfixes/mcol_4623.test
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
-- source ../include/have_columnstore.inc
|
||||||
|
--disable_warnings
|
||||||
|
DROP DATABASE IF EXISTS mcol_4623;
|
||||||
|
--enable_warnings
|
||||||
|
CREATE DATABASE mcol_4623;
|
||||||
|
USE mcol_4623;
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a DOUBLE UNSIGNED) Engine=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES (1000);
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
--disable_warnings
|
||||||
|
DROP TABLE t1;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a TIME) ENGINE=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES ('17:31:27');
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
--disable_warnings
|
||||||
|
DROP TABLE t1;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a DATE) ENGINE=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES ('2023-07-23');
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
--disable_warnings
|
||||||
|
DROP TABLE t1;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a DATETIME) ENGINE=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES ('2009-03-17 14:30:45');
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
--disable_warnings
|
||||||
|
DROP TABLE t1;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a TIMESTAMP) ENGINE=ColumnStore;
|
||||||
|
INSERT INTO t1 VALUES ('2017-01-01 04:30:45');
|
||||||
|
SELECT SEC_TO_TIME(a) FROM t1 ORDER BY 1;
|
||||||
|
--disable_warnings
|
||||||
|
DROP TABLE t1;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
--disable_warnings
|
||||||
|
DROP DATABASE mcol_4623;
|
||||||
|
--enable_warnings
|
||||||
@@ -67,33 +67,73 @@ string Func_sec_to_time::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool&
|
|||||||
case execplan::CalpontSystemCatalog::USMALLINT:
|
case execplan::CalpontSystemCatalog::USMALLINT:
|
||||||
{
|
{
|
||||||
val = parm[0]->data()->getIntVal(row, isNull);
|
val = parm[0]->data()->getIntVal(row, isNull);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||||
|
case execplan::CalpontSystemCatalog::UDOUBLE:
|
||||||
{
|
{
|
||||||
datatypes::TDouble d(parm[0]->data()->getDoubleVal(row, isNull));
|
datatypes::TDouble d(parm[0]->data()->getDoubleVal(row, isNull));
|
||||||
val = d.toMCSSInt64Round();
|
val = d.toMCSSInt64Round();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::FLOAT:
|
case execplan::CalpontSystemCatalog::FLOAT:
|
||||||
|
case execplan::CalpontSystemCatalog::UFLOAT:
|
||||||
{
|
{
|
||||||
datatypes::TDouble d(parm[0]->data()->getFloatVal(row, isNull));
|
datatypes::TDouble d(parm[0]->data()->getFloatVal(row, isNull));
|
||||||
val = d.toMCSSInt64Round();
|
val = d.toMCSSInt64Round();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case execplan::CalpontSystemCatalog::LONGDOUBLE:
|
||||||
|
{
|
||||||
|
datatypes::TLongDouble d(parm[0]->data()->getLongDoubleVal(row, isNull));
|
||||||
|
val = d.toMCSSInt64Round();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||||
case execplan::CalpontSystemCatalog::UDECIMAL:
|
case execplan::CalpontSystemCatalog::UDECIMAL:
|
||||||
|
{
|
||||||
val = parm[0]->data()->getDecimalVal(row, isNull).toSInt64Round();
|
val = parm[0]->data()->getDecimalVal(row, isNull).toSInt64Round();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::CHAR:
|
case execplan::CalpontSystemCatalog::CHAR:
|
||||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||||
case execplan::CalpontSystemCatalog::TEXT:
|
case execplan::CalpontSystemCatalog::TEXT:
|
||||||
{
|
{
|
||||||
val = parm[0]->data()->getIntVal(row, isNull);
|
val = parm[0]->data()->getIntVal(row, isNull);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case execplan::CalpontSystemCatalog::TIME:
|
||||||
|
{
|
||||||
|
int64_t timeVal = parm[0]->data()->getTimeIntVal(row, isNull);
|
||||||
|
uint32_t hour = (uint32_t)((timeVal >> 40) & 0xfff);
|
||||||
|
uint32_t minute = (uint32_t)((timeVal >> 32) & 0xff);
|
||||||
|
uint32_t second = (uint32_t)((timeVal >> 24) & 0xff);
|
||||||
|
val = (int64_t)(hour * 3600 + minute * 60 + second);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case execplan::CalpontSystemCatalog::DATE:
|
||||||
|
case execplan::CalpontSystemCatalog::DATETIME:
|
||||||
|
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||||
|
{
|
||||||
|
return "838:59:59";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case execplan::CalpontSystemCatalog::BLOB:
|
||||||
|
case execplan::CalpontSystemCatalog::CLOB:
|
||||||
|
case execplan::CalpontSystemCatalog::VARBINARY:
|
||||||
|
case execplan::CalpontSystemCatalog::STRINT:
|
||||||
|
case execplan::CalpontSystemCatalog::NUM_OF_COL_DATA_TYPE:
|
||||||
|
case execplan::CalpontSystemCatalog::UNDEFINED:
|
||||||
|
{
|
||||||
|
val = parm[0]->data()->getIntVal(row, isNull);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user