You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
Adding support for enum continuation
This commit is contained in:
@@ -283,6 +283,12 @@ const string& TypeHandlerBit::name() const
|
|||||||
return xname;
|
return xname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string& TypeHandlerEnum::name() const
|
||||||
|
{
|
||||||
|
static const string xname = "ENUM";
|
||||||
|
return xname;
|
||||||
|
}
|
||||||
|
|
||||||
TypeHandlerBit mcs_type_handler_bit;
|
TypeHandlerBit mcs_type_handler_bit;
|
||||||
|
|
||||||
TypeHandlerSInt8 mcs_type_handler_sint8;
|
TypeHandlerSInt8 mcs_type_handler_sint8;
|
||||||
@@ -297,6 +303,8 @@ TypeHandlerUInt24 mcs_type_handler_uint24;
|
|||||||
TypeHandlerUInt32 mcs_type_handler_uint32;
|
TypeHandlerUInt32 mcs_type_handler_uint32;
|
||||||
TypeHandlerUInt64 mcs_type_handler_uint64;
|
TypeHandlerUInt64 mcs_type_handler_uint64;
|
||||||
|
|
||||||
|
TypeHandlerEnum mcs_type_handler_enum;
|
||||||
|
|
||||||
TypeHandlerSFloat mcs_type_handler_sfloat;
|
TypeHandlerSFloat mcs_type_handler_sfloat;
|
||||||
TypeHandlerSDouble mcs_type_handler_sdouble;
|
TypeHandlerSDouble mcs_type_handler_sdouble;
|
||||||
TypeHandlerSLongDouble mcs_type_handler_slongdouble;
|
TypeHandlerSLongDouble mcs_type_handler_slongdouble;
|
||||||
@@ -344,6 +352,8 @@ const TypeHandler* TypeHandler::find(SystemCatalog::ColDataType typeCode,
|
|||||||
case SystemCatalog::UFLOAT: return &mcs_type_handler_ufloat;
|
case SystemCatalog::UFLOAT: return &mcs_type_handler_ufloat;
|
||||||
case SystemCatalog::UDOUBLE: return &mcs_type_handler_udouble;
|
case SystemCatalog::UDOUBLE: return &mcs_type_handler_udouble;
|
||||||
|
|
||||||
|
case SystemCatalog::ENUM: return &mcs_type_handler_enum;
|
||||||
|
|
||||||
case SystemCatalog::DECIMAL:
|
case SystemCatalog::DECIMAL:
|
||||||
if (static_cast<uint32_t>(ct.colWidth) < datatypes::MAXDECIMALWIDTH)
|
if (static_cast<uint32_t>(ct.colWidth) < datatypes::MAXDECIMALWIDTH)
|
||||||
return &mcs_type_handler_sdecimal64;
|
return &mcs_type_handler_sdecimal64;
|
||||||
@@ -434,6 +444,8 @@ const TypeHandler* TypeHandler::find_by_ddltype(const ddlpackage::ColumnType& ct
|
|||||||
case ddlpackage::DDL_UNSIGNED_INT: return &mcs_type_handler_uint32;
|
case ddlpackage::DDL_UNSIGNED_INT: return &mcs_type_handler_uint32;
|
||||||
case ddlpackage::DDL_UNSIGNED_BIGINT: return &mcs_type_handler_uint64;
|
case ddlpackage::DDL_UNSIGNED_BIGINT: return &mcs_type_handler_uint64;
|
||||||
|
|
||||||
|
case ddlpackage::DDL_ENUM: return &mcs_type_handler_sint16;
|
||||||
|
|
||||||
case ddlpackage::DDL_UNSIGNED_DECIMAL:
|
case ddlpackage::DDL_UNSIGNED_DECIMAL:
|
||||||
case ddlpackage::DDL_UNSIGNED_NUMERIC:
|
case ddlpackage::DDL_UNSIGNED_NUMERIC:
|
||||||
|
|
||||||
@@ -1543,12 +1555,29 @@ boost::any TypeHandlerVarbinary::getNullValueForType(const SystemCatalog::TypeAt
|
|||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
boost::any TypeHandlerBit::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
boost::any TypeHandlerBit::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||||
const ConvertFromStringParam& prm, const std::string& data,
|
const ConvertFromStringParam& prm, const std::string& data,
|
||||||
bool& pushWarning) const
|
bool& pushWarning) const
|
||||||
{
|
{
|
||||||
return dataconvert::DataConvert::StringToBit(colType, prm, data, pushWarning);
|
return dataconvert::DataConvert::StringToBit(colType, prm, data, pushWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::any TypeHandlerEnum::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||||
|
const ConvertFromStringParam&, const std::string& data,
|
||||||
|
bool&) const
|
||||||
|
{
|
||||||
|
unsigned short val = 0;
|
||||||
|
|
||||||
|
for (; val<colType.enumVals.size(); ++val) {
|
||||||
|
if (colType.enumVals[val] == data) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::any value = val;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
boost::any TypeHandlerSInt8::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
boost::any TypeHandlerSInt8::convertFromString(const SystemCatalog::TypeAttributesStd& colType,
|
||||||
const ConvertFromStringParam& prm, const std::string& data,
|
const ConvertFromStringParam& prm, const std::string& data,
|
||||||
bool& pushWarning) const
|
bool& pushWarning) const
|
||||||
|
@@ -152,6 +152,7 @@ class SystemCatalog
|
|||||||
enum ColDataType
|
enum ColDataType
|
||||||
{
|
{
|
||||||
BIT, /*!< BIT type */
|
BIT, /*!< BIT type */
|
||||||
|
ENUM, /*!< ENUM type */
|
||||||
TINYINT, /*!< TINYINT type */
|
TINYINT, /*!< TINYINT type */
|
||||||
CHAR, /*!< CHAR type */
|
CHAR, /*!< CHAR type */
|
||||||
SMALLINT, /*!< SMALLINT type */
|
SMALLINT, /*!< SMALLINT type */
|
||||||
@@ -195,6 +196,8 @@ class SystemCatalog
|
|||||||
int32_t colWidth;
|
int32_t colWidth;
|
||||||
int32_t scale; // number after decimal points
|
int32_t scale; // number after decimal points
|
||||||
int32_t precision;
|
int32_t precision;
|
||||||
|
std::vector<std::string> enumVals;
|
||||||
|
|
||||||
TypeAttributesStd() : colWidth(0), scale(0), precision(-1)
|
TypeAttributesStd() : colWidth(0), scale(0), precision(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1143,6 +1146,65 @@ class TypeHandlerBit : public TypeHandler
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// QQ: perhaps not needed yet
|
||||||
|
class TypeHandlerEnum : public TypeHandler
|
||||||
|
{
|
||||||
|
const string& name() const override;
|
||||||
|
code_t code() const override
|
||||||
|
{
|
||||||
|
return SystemCatalog::ENUM;
|
||||||
|
}
|
||||||
|
size_t ColWriteBatch(WriteBatchField* /*field*/, const unsigned char* /*buf*/, bool /*nullVal*/,
|
||||||
|
ColBatchWriter& /*writer*/) const override
|
||||||
|
{
|
||||||
|
idbassert(0); // QQ
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int storeValueToField(rowgroup::Row& /*row*/, int /*pos*/, StoreField* /*f*/) const override
|
||||||
|
{
|
||||||
|
idbassert(0); // QQ
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
std::string format(const SimpleValue& /*v*/, const SystemCatalog::TypeAttributesStd& /*attr*/) const override
|
||||||
|
{
|
||||||
|
return "0"; // QQ
|
||||||
|
}
|
||||||
|
std::string formatPartitionInfo(const SystemCatalog::TypeAttributesStd& /*attr*/,
|
||||||
|
const MinMaxInfo& /*i*/) const override
|
||||||
|
{
|
||||||
|
idbassert(0);
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
execplan::SimpleColumn* newSimpleColumn(const DatabaseQualifiedColumnName& /*name*/,
|
||||||
|
SystemCatalog::TypeHolderStd& /*ct*/,
|
||||||
|
const SimpleColumnParam& /*prm*/) const override
|
||||||
|
{
|
||||||
|
idbassert(0);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
SimpleValue toSimpleValue(const SessionParam& /*sp*/, const SystemCatalog::TypeAttributesStd& /*attr*/,
|
||||||
|
const char* /*str*/, round_style_t& /*rf*/) const override
|
||||||
|
{
|
||||||
|
idbassert(0);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd& /*attr*/) const override
|
||||||
|
{
|
||||||
|
// TODO: How to communicate with write engine?
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& /*colType*/,
|
||||||
|
const ConvertFromStringParam& /*prm*/, const std::string& /*str*/,
|
||||||
|
bool& /*pushWarning*/) const override;
|
||||||
|
|
||||||
|
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd& /*attr*/) const override
|
||||||
|
{
|
||||||
|
idbassert(0);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class TypeHandlerInt : public TypeHandler
|
class TypeHandlerInt : public TypeHandler
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
@@ -217,6 +217,7 @@ enum DDL_DATATYPES
|
|||||||
/** @brief Datatype string list
|
/** @brief Datatype string list
|
||||||
*/
|
*/
|
||||||
const std::string DDLDatatypeString[] = {"bit",
|
const std::string DDLDatatypeString[] = {"bit",
|
||||||
|
"enum",
|
||||||
"tinyint",
|
"tinyint",
|
||||||
"char",
|
"char",
|
||||||
"smallint",
|
"smallint",
|
||||||
@@ -261,6 +262,7 @@ const std::string AlterActionString[] = {
|
|||||||
*/
|
*/
|
||||||
const int DDLDatatypeLength[] = {
|
const int DDLDatatypeLength[] = {
|
||||||
1, // BIT
|
1, // BIT
|
||||||
|
2, // ENUM
|
||||||
1, // TINYINT
|
1, // TINYINT
|
||||||
1, // CHAR
|
1, // CHAR
|
||||||
2, // SMALLINT
|
2, // SMALLINT
|
||||||
|
@@ -1138,6 +1138,7 @@ int ColumnType::unserialize(ByteStream& bytestream)
|
|||||||
bytestream >> nextVal;
|
bytestream >> nextVal;
|
||||||
bytestream >> charsetNum;
|
bytestream >> charsetNum;
|
||||||
bytestream >> enumValuesNum;
|
bytestream >> enumValuesNum;
|
||||||
|
fEnumValues.clear();
|
||||||
|
|
||||||
for (size_t i = 0; i<fEnumValues.size(); ++i) {
|
for (size_t i = 0; i<fEnumValues.size(); ++i) {
|
||||||
std::string value;
|
std::string value;
|
||||||
|
@@ -108,6 +108,12 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case (CalpontSystemCatalog::ENUM):
|
||||||
|
if (newType.fType == DDL_ENUM && colType.enumVals == newType.fEnumValues)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case (CalpontSystemCatalog::TINYINT):
|
case (CalpontSystemCatalog::TINYINT):
|
||||||
if (newType.fType == DDL_TINYINT && colType.precision == newType.fPrecision &&
|
if (newType.fType == DDL_TINYINT && colType.precision == newType.fPrecision &&
|
||||||
colType.scale == newType.fScale)
|
colType.scale == newType.fScale)
|
||||||
|
@@ -314,6 +314,12 @@ boost::any DDLIndexPopulator::convertData(const CalpontSystemCatalog::ColType& c
|
|||||||
switch (colType.colDataType)
|
switch (colType.colDataType)
|
||||||
{
|
{
|
||||||
case CalpontSystemCatalog::BIT:
|
case CalpontSystemCatalog::BIT:
|
||||||
|
case CalpontSystemCatalog::ENUM:
|
||||||
|
{
|
||||||
|
string strData(colType.fEnumValues[data]);
|
||||||
|
|
||||||
|
return *reinterpret_cast<string*>(&strData);
|
||||||
|
}
|
||||||
case execplan::CalpontSystemCatalog::TINYINT: return *reinterpret_cast<char*>(&data);
|
case execplan::CalpontSystemCatalog::TINYINT: return *reinterpret_cast<char*>(&data);
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::SMALLINT: return *reinterpret_cast<short*>(&data);
|
case execplan::CalpontSystemCatalog::SMALLINT: return *reinterpret_cast<short*>(&data);
|
||||||
@@ -460,6 +466,10 @@ bool DDLIndexPopulator::checkNotNull(const IdxTuple& data, const CalpontSystemCa
|
|||||||
{
|
{
|
||||||
case CalpontSystemCatalog::BIT: break;
|
case CalpontSystemCatalog::BIT: break;
|
||||||
|
|
||||||
|
case execplan::CalpontSystemCatalog::ENUM:
|
||||||
|
isNull = any_cast<short>(data.data) == any_cast<short>(nullvalue);
|
||||||
|
break;
|
||||||
|
|
||||||
case execplan::CalpontSystemCatalog::TINYINT:
|
case execplan::CalpontSystemCatalog::TINYINT:
|
||||||
isNull = any_cast<char>(data.data) == any_cast<char>(nullvalue);
|
isNull = any_cast<char>(data.data) == any_cast<char>(nullvalue);
|
||||||
break;
|
break;
|
||||||
|
@@ -197,6 +197,8 @@ execplan::CalpontSystemCatalog::ColDataType DDLPackageProcessor::convertDataType
|
|||||||
|
|
||||||
case ddlpackage::DDL_TEXT: colDataType = CalpontSystemCatalog::TEXT; break;
|
case ddlpackage::DDL_TEXT: colDataType = CalpontSystemCatalog::TEXT; break;
|
||||||
|
|
||||||
|
case ddlpackage::DDL_ENUM: colDataType = CalpontSystemCatalog::ENUM; break;
|
||||||
|
|
||||||
default: throw runtime_error("Unsupported datatype!");
|
default: throw runtime_error("Unsupported datatype!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -471,7 +471,7 @@ void AggregateColumn::evaluate(Row& row, bool& isNull)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CalpontSystemCatalog::SMALLINT:
|
case CalpontSystemCatalog::SMALLINT:
|
||||||
if (row.equals<2>(SMALLINTNULL, fInputIndex))
|
if (row.equals<2>(SMALLINTNULL, fInputIndex))
|
||||||
isNull = true;
|
isNull = true;
|
||||||
else
|
else
|
||||||
|
@@ -113,6 +113,8 @@ const string colDataTypeToString(CalpontSystemCatalog::ColDataType cdt)
|
|||||||
{
|
{
|
||||||
case CalpontSystemCatalog::BIT: return "bit"; break;
|
case CalpontSystemCatalog::BIT: return "bit"; break;
|
||||||
|
|
||||||
|
case CalpontSystemCatalog::ENUM: return "enum"; break;
|
||||||
|
|
||||||
case CalpontSystemCatalog::TINYINT: return "tinyint"; break;
|
case CalpontSystemCatalog::TINYINT: return "tinyint"; break;
|
||||||
|
|
||||||
case CalpontSystemCatalog::CHAR: return "char"; break;
|
case CalpontSystemCatalog::CHAR: return "char"; break;
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
namespace joblist
|
namespace joblist
|
||||||
{
|
{
|
||||||
|
const uint64_t ENUMNULL = 0xffff;
|
||||||
const uint64_t BIGINTNULL = 0x8000000000000000ULL;
|
const uint64_t BIGINTNULL = 0x8000000000000000ULL;
|
||||||
const uint64_t BIGINTEMPTYROW = 0x8000000000000001ULL;
|
const uint64_t BIGINTEMPTYROW = 0x8000000000000001ULL;
|
||||||
const uint32_t INTNULL = 0x80000000;
|
const uint32_t INTNULL = 0x80000000;
|
||||||
|
@@ -199,6 +199,8 @@ inline int convertDataType(int dataType)
|
|||||||
|
|
||||||
case ddlpackage::DDL_UNSIGNED_DOUBLE: calpontDataType = execplan::CalpontSystemCatalog::UDOUBLE; break;
|
case ddlpackage::DDL_UNSIGNED_DOUBLE: calpontDataType = execplan::CalpontSystemCatalog::UDOUBLE; break;
|
||||||
|
|
||||||
|
case ddlpackage::DDL_ENUM: calpontDataType = execplan::CalpontSystemCatalog::ENUM; break;
|
||||||
|
|
||||||
default: throw runtime_error("Unsupported datatype!");
|
default: throw runtime_error("Unsupported datatype!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user