1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2026-01-06 08:21:10 +03:00

MCOL-392 Add initial TIME datatype support

This commit is contained in:
Andrew Hutchings
2018-04-23 19:20:31 +01:00
parent b584a7f555
commit 3c1ebd8b94
109 changed files with 2241 additions and 47 deletions

View File

@@ -902,7 +902,8 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
{
bool bSatVal = false;
if ( column.dataType != CalpontSystemCatalog::DATETIME )
if ( column.dataType != CalpontSystemCatalog::DATETIME &&
column.dataType != CalpontSystemCatalog::TIME )
{
if (nullFlag)
{
@@ -976,6 +977,59 @@ void BulkLoadBuffer::convert(char* field, int fieldLength,
pVal = &llVal;
}
else if (column.dataType == CalpontSystemCatalog::TIME)
{
// time conversion
int rc = 0;
if (nullFlag)
{
if (column.fWithDefault)
{
llDate = column.fDefaultInt;
// fall through to update saturation and min/max
}
else
{
llDate = joblist::TIMENULL;
pVal = &llDate;
break;
}
}
else
{
if (fImportDataMode != IMPORT_DATA_TEXT)
{
memcpy(&llDate, field, sizeof(llDate));
if (!dataconvert::DataConvert::isColumnTimeValid(
llDate))
rc = -1;
}
else
{
llDate = dataconvert::DataConvert::convertColumnTime(
field, dataconvert::CALPONTTIME_ENUM,
rc, fieldLength );
}
}
if (rc == 0)
{
if (llDate < bufStats.minBufferVal)
bufStats.minBufferVal = llDate;
if (llDate > bufStats.maxBufferVal)
bufStats.maxBufferVal = llDate;
}
else
{
llDate = 0;
bufStats.satCount++;
}
pVal = &llDate;
}
else
{
// datetime conversion
@@ -2973,6 +3027,11 @@ bool BulkLoadBuffer::isBinaryFieldNull(void* val,
if ((*(uint64_t*)val) == joblist::DATETIMENULL)
isNullFlag = true;
}
else if (dt == execplan::CalpontSystemCatalog::TIME)
{
if ((*(uint64_t*)val) == joblist::TIMENULL)
isNullFlag = true;
}
else
{
if ((*(uint64_t*)val) == joblist::BIGINTNULL)

View File

@@ -978,6 +978,11 @@ void TableInfo::reportTotals(double elapsedTime)
ossSatCnt <<
"invalid date/times replaced with zero value : ";
}
else if (fColumns[i].column.dataType == CalpontSystemCatalog::TIME)
{
ossSatCnt <<
"invalid times replaced with zero value : ";
}
else if (fColumns[i].column.dataType == CalpontSystemCatalog::CHAR)
ossSatCnt <<
"character strings truncated: ";

View File

@@ -274,6 +274,13 @@ inline boost::any getNullValueForType(const execplan::CalpontSystemCatalog::ColT
}
break;
case execplan::CalpontSystemCatalog::TIME:
{
long long d = joblist::TIMENULL;
value = d;
}
break;
case execplan::CalpontSystemCatalog::CHAR:
{
std::string charnull;
@@ -433,6 +440,10 @@ inline int convertDataType(int dataType)
calpontDataType = CalpontSystemCatalog::DATETIME;
break;
case ddlpackage::DDL_TIME:
calpontDataType = CalpontSystemCatalog::TIME;
break;
case ddlpackage::DDL_CLOB:
calpontDataType = CalpontSystemCatalog::CLOB;
break;

View File

@@ -1781,6 +1781,7 @@ uint8_t WE_DMLCommandProc::processBatchInsertBinary(messageqcpp::ByteStream& bs,
case execplan::CalpontSystemCatalog::BIGINT:
case execplan::CalpontSystemCatalog::DATETIME:
case execplan::CalpontSystemCatalog::TIME:
case execplan::CalpontSystemCatalog::UBIGINT:
bs >> val64;
@@ -2981,6 +2982,13 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
break;
}
case CalpontSystemCatalog::TIME:
{
intColVal = row.getIntField<8>(fetchColPos);
value = DataConvert::timeToString(intColVal, colType.precision);
break;
}
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
{
@@ -3309,6 +3317,13 @@ uint8_t WE_DMLCommandProc::processUpdate(messageqcpp::ByteStream& bs,
break;
}
case CalpontSystemCatalog::TIME:
{
intColVal = row.getIntField<8>(fetchColPos);
value = DataConvert::timeToString(intColVal, colType.precision);
break;
}
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
{

View File

@@ -420,6 +420,7 @@ void Convertor::convertColType(CalpontSystemCatalog::ColDataType dataType,
// Map BIGINT and DATETIME to WR_LONGLONG
case CalpontSystemCatalog::BIGINT :
case CalpontSystemCatalog::DATETIME :
case CalpontSystemCatalog::TIME :
internalType = WriteEngine::WR_LONGLONG;
break;
@@ -629,6 +630,7 @@ void Convertor::convertColType(ColStruct* curStruct)
// Map BIGINT and DATETIME to WR_LONGLONG
case CalpontSystemCatalog::BIGINT :
case CalpontSystemCatalog::DATETIME :
case CalpontSystemCatalog::TIME :
*internalType = WriteEngine::WR_LONGLONG;
break;
@@ -792,6 +794,7 @@ int Convertor::getCorrectRowWidth(CalpontSystemCatalog::ColDataType dataType, in
break;
case CalpontSystemCatalog::DATETIME:
case CalpontSystemCatalog::TIME:
newWidth = 8;
break;

View File

@@ -1907,6 +1907,10 @@ void WESDHandler::onCleanupResult(int PmId, messageqcpp::SBS& Sbs)
ossSatCnt << "invalid date/times replaced with zero value: ";
break;
case CalpontSystemCatalog::TIME:
ossSatCnt << "invalid times replaced with zero value: ";
break;
case CalpontSystemCatalog::CHAR:
ossSatCnt << "character strings truncated: ";
break;

View File

@@ -443,6 +443,8 @@ void WriteEngineWrapper::convertValue(const ColType colType, void* valArray, con
case WriteEngine::WR_LONGLONG:
if (data.type() == typeid(long long))
((long long*)valArray)[pos] = boost::any_cast<long long>(data);
else if (data.type() == typeid(long))
((long long*)valArray)[pos] = (long long)boost::any_cast<long>(data);
else
((long long*)valArray)[pos] = boost::any_cast<uint64_t>(data);

View File

@@ -1116,6 +1116,22 @@ void XMLJob::fillInXMLDataNotNullDefault(
break;
}
case execplan::CalpontSystemCatalog::TIME:
{
int convertStatus;
int64_t dt =
dataconvert::DataConvert::convertColumnTime(
col_defaultValue.c_str(),
dataconvert::CALPONTTIME_ENUM, convertStatus,
col_defaultValue.length() );
if (convertStatus != 0)
bDefaultConvertError = true;
col.fDefaultInt = dt;
break;
}
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UFLOAT: