mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 19:42:00 +00:00
overload getPostitionByName function
This commit is contained in:
parent
a09422de7b
commit
61a6117a33
@ -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())
|
||||
|
@ -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; }
|
||||
|
Loading…
Reference in New Issue
Block a user