```
select tupleElement(CAST(tuple(1,2),'Tuple(x UInt64, y UInt64)'), 'x') 
-- ok

select tupleElement(CAST(tuple(1,2),'Tuple(x UInt64, y UInt64)'), 'z')

-- fails
-- Code: 10. DB::Exception: Received from localhost:9000. DB::Exception: Tuple doesn't have element with name 'z': While processing tupleElement(CAST((1, 2), 'Tuple(x UInt64, y UInt64)'), 'z'). (NOT_FOUND_COLUMN_IN_BLOCK)
```
Proposal - add the 3rd parameter to the tupleElement function and return it if tuple doesn't have a member.

Why? Tuple comes from object('JSON'), sometimes some fields are missing in some jsons.
{
        if (
            checkAndGetColumnConst<ColumnUInt8>(index_column.get())
                || checkAndGetColumnConst<ColumnUInt16>(index_column.get())
                || checkAndGetColumnConst<ColumnUInt32>(index_column.get())
                || checkAndGetColumnConst<ColumnUInt64>(index_column.get())
        )
        {
            size_t index = index_column->getUInt(0);
            if (index == 0)
                throw Exception("Indices in tuples are 1-based.", ErrorCodes::ILLEGAL_INDEX);
            if (index > tuple.getElements().size())
                throw Exception("Index for tuple element is out of range.", ErrorCodes::ILLEGAL_INDEX);
            return index - 1;
        }
        else if (const auto * name_col = checkAndGetColumnConst<ColumnString>(index_column.get()))
        {
            return tuple.getPositionByName(name_col->getValue<String>());
        }
        else
            throw Exception("Second argument to " + getName() + " must be a constant UInt or String", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
    }
};
}
void registerFunctionTupleElement(FunctionFactory & factory)
{
    factory.registerFunction<FunctionTupleElement>();
}
}