diff --git a/dbms/src/Storages/System/StorageSystemDataTypeFamilies.cpp b/dbms/src/Storages/System/StorageSystemDataTypeFamilies.cpp index 5d731803d4b..a97ac696977 100644 --- a/dbms/src/Storages/System/StorageSystemDataTypeFamilies.cpp +++ b/dbms/src/Storages/System/StorageSystemDataTypeFamilies.cpp @@ -12,32 +12,33 @@ namespace { void setTypePropertries(const DataTypePtr data_type, MutableColumns & res_columns) { - res_columns[3]->insert(UInt64(data_type->isParametric())); - res_columns[4]->insert(UInt64(data_type->haveSubtypes())); - res_columns[5]->insert(UInt64(data_type->cannotBeStoredInTables())); - res_columns[6]->insert(UInt64(data_type->isComparable())); - res_columns[7]->insert(UInt64(data_type->canBeComparedWithCollation())); - res_columns[8]->insert(UInt64(data_type->canBeUsedAsVersion())); - res_columns[9]->insert(UInt64(data_type->isSummable())); - res_columns[10]->insert(UInt64(data_type->canBeUsedInBitOperations())); - res_columns[11]->insert(UInt64(data_type->canBeUsedInBooleanContext())); - res_columns[12]->insert(UInt64(data_type->isCategorial())); - res_columns[13]->insert(UInt64(data_type->isNullable())); - res_columns[14]->insert(UInt64(data_type->onlyNull())); - res_columns[15]->insert(UInt64(data_type->canBeInsideNullable())); + res_columns[4]->insert(UInt64(data_type->isParametric())); + res_columns[5]->insert(UInt64(data_type->haveSubtypes())); + res_columns[6]->insert(UInt64(data_type->cannotBeStoredInTables())); + res_columns[7]->insert(UInt64(data_type->isComparable())); + res_columns[8]->insert(UInt64(data_type->canBeComparedWithCollation())); + res_columns[9]->insert(UInt64(data_type->canBeUsedAsVersion())); + res_columns[10]->insert(UInt64(data_type->isSummable())); + res_columns[11]->insert(UInt64(data_type->canBeUsedInBitOperations())); + res_columns[12]->insert(UInt64(data_type->canBeUsedInBooleanContext())); + res_columns[13]->insert(UInt64(data_type->isCategorial())); + res_columns[14]->insert(UInt64(data_type->isNullable())); + res_columns[15]->insert(UInt64(data_type->onlyNull())); + res_columns[16]->insert(UInt64(data_type->canBeInsideNullable())); } void setComplexTypeProperties(const String & name, MutableColumns & res_columns) { - res_columns[3]->insert(UInt64(1)); //complex types are always parametric + res_columns[3]->insert(Null()); + res_columns[4]->insert(UInt64(1)); //complex types are always parametric if (name == "AggregateFunction") - res_columns[4]->insert(UInt64(0)); + res_columns[5]->insert(UInt64(0)); else if (name == "Tuple") - res_columns[4]->insert(Null()); + res_columns[5]->insert(Null()); else - res_columns[4]->insert(UInt64(1)); + res_columns[5]->insert(UInt64(1)); - for (size_t i = 5; i < StorageSystemDataTypeFamilies::getNamesAndTypes().size(); ++i) + for (size_t i = 6; i < StorageSystemDataTypeFamilies::getNamesAndTypes().size(); ++i) res_columns[i]->insert(Null()); } @@ -80,13 +81,27 @@ void StorageSystemDataTypeFamilies::fillData(MutableColumns & res_columns) const try { DataTypePtr type_ptr; + + Field size = Null(); // hardcoded cases for simple parametric types if (boost::starts_with(name, "Enum")) + { type_ptr = factory.get(name, createFakeEnumCreationAst()); + size = type_ptr->getMaximumSizeOfValueInMemory(); + } else if (name == "FixedString" || name == "BINARY") + { type_ptr = factory.get(name, createFakeFixedStringAst()); + } else + { type_ptr = factory.get(name); + if (type_ptr->haveMaximumSizeOfValue()) + size = type_ptr->getMaximumSizeOfValueInMemory(); + } + + res_columns[3]->insert(size); + setTypePropertries(type_ptr, res_columns); } catch (Exception & ex) diff --git a/dbms/src/Storages/System/StorageSystemDataTypeFamilies.h b/dbms/src/Storages/System/StorageSystemDataTypeFamilies.h index bc875f6130c..da2b338d53b 100644 --- a/dbms/src/Storages/System/StorageSystemDataTypeFamilies.h +++ b/dbms/src/Storages/System/StorageSystemDataTypeFamilies.h @@ -27,6 +27,7 @@ public: {"name", std::make_shared()}, {"case_insensivie", std::make_shared(std::make_shared())}, {"alias_to", std::make_shared(std::make_shared())}, + {"size_in_bytes", std::make_shared(std::make_shared())}, {"parametric", std::make_shared(std::make_shared())}, {"have_subtypes", std::make_shared(std::make_shared())}, {"cannot_be_stored_in_tables", std::make_shared(std::make_shared())},