overload getPostitionByName function

This commit is contained in:
lokax 2022-07-08 14:16:01 +08:00
parent a09422de7b
commit 61a6117a33
2 changed files with 15 additions and 0 deletions

View File

@ -214,6 +214,20 @@ size_t DataTypeTuple::getPositionByName(const String & name) const
throw Exception("Tuple doesn't have element with name '" + name + "'", ErrorCodes::NOT_FOUND_COLUMN_IN_BLOCK);
}
bool DataTypeTuple::getPositionByName(const String & name, size_t & index) const
{
size_t size = elems.size();
for (size_t i = 0; i < size; ++i)
{
if (names[i] == name)
{
index = i;
return true;
}
}
return false;
}
String DataTypeTuple::getNameByPosition(size_t i) const
{
if (i == 0 || i > names.size())

View File

@ -60,6 +60,7 @@ public:
const Strings & getElementNames() const { return names; }
size_t getPositionByName(const String & name) const;
bool getPositionByName(const String & name, size_t & index) const;
String getNameByPosition(size_t i) const;
bool haveExplicitNames() const { return have_explicit_names; }