Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions mysql-test/columnstore/bugfixes/mcol_4623.result
Original file line number Diff line number Diff line change
@@ -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 changes: 45 additions & 0 deletions mysql-test/columnstore/bugfixes/mcol_4623.test
Original file line number Diff line number Diff line change
@@ -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
44 changes: 42 additions & 2 deletions utils/funcexp/func_sec_to_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,73 @@ string Func_sec_to_time::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool&
case execplan::CalpontSystemCatalog::USMALLINT:
{
val = parm[0]->data()->getIntVal(row, isNull);
break;
}
break;

case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
{
datatypes::TDouble d(parm[0]->data()->getDoubleVal(row, isNull));
val = d.toMCSSInt64Round();
break;
}

case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
{
datatypes::TDouble d(parm[0]->data()->getFloatVal(row, isNull));
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::UDECIMAL:
{
val = parm[0]->data()->getDecimalVal(row, isNull).toSInt64Round();
break;
}

case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::TEXT:
{
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;
}

Expand Down