Fix tests.

This commit is contained in:
Nikolai Kochetov 2020-10-21 23:05:10 +03:00
parent fd77ca8251
commit 69279e6d76
4 changed files with 7 additions and 23 deletions

View File

@ -60,8 +60,8 @@ static void checkTupleNames(const Strings & names, std::function<void(const char
}
}
DataTypeTuple::DataTypeTuple(const DataTypes & elems_, const Strings & names_)
: elems(elems_), names(names_), have_explicit_names(true)
DataTypeTuple::DataTypeTuple(const DataTypes & elems_, const Strings & names_, bool serialize_names_)
: elems(elems_), names(names_), have_explicit_names(true), serialize_names(serialize_names_)
{
size_t size = elems.size();
if (names.size() != size)
@ -88,7 +88,7 @@ std::string DataTypeTuple::doGetName() const
if (i != 0)
s << ", ";
if (have_explicit_names)
if (have_explicit_names && serialize_names)
s << backQuoteIfNeed(names[i]) << ' ';
s << elems[i]->getName();

View File

@ -22,11 +22,12 @@ private:
DataTypes elems;
Strings names;
bool have_explicit_names;
bool serialize_names;
public:
static constexpr bool is_parametric = true;
DataTypeTuple(const DataTypes & elems);
DataTypeTuple(const DataTypes & elems, const Strings & names);
DataTypeTuple(const DataTypes & elems, const Strings & names, bool serialize_names_ = true);
static bool canBeCreatedWithNames(const Strings & names);

View File

@ -68,7 +68,7 @@ public:
/// Create named tuple if possible.
if (DataTypeTuple::canBeCreatedWithNames(names))
return std::make_shared<DataTypeTuple>(types, names);
return std::make_shared<DataTypeTuple>(types, names, false);
return std::make_shared<DataTypeTuple>(types);
}

View File

@ -8,23 +8,6 @@
namespace DB
{
namespace
{
class ParserNestedOrExpression : public IParserBase
{
protected:
const char * getName() const override { return "nested or expression"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override
{
ParserNestedTable nested_parser;
ParserExpression expr_parser;
return nested_parser.parse(pos, node, expected) || expr_parser.parse(pos, node, expected);
}
};
}
bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
{
ParserNestedTable nested;
@ -95,7 +78,7 @@ bool ParserDataType::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
++pos;
/// Parse optional parameters
ParserList args_parser(std::make_unique<ParserNestedOrExpression>(), std::make_unique<ParserToken>(TokenType::Comma));
ParserList args_parser(std::make_unique<ParserExpression>(), std::make_unique<ParserToken>(TokenType::Comma));
ASTPtr expr_list_args;
if (!args_parser.parse(pos, expr_list_args, expected))