mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
support ILIKE, and separate like,limit function.
This commit is contained in:
parent
dc0e276bba
commit
406f384a45
@ -37,7 +37,11 @@ String InterpreterShowTablesQuery::getRewrittenQuery()
|
||||
|
||||
if (!query.like.empty())
|
||||
{
|
||||
rewritten_query << " WHERE name " << (query.not_like ? "NOT " : "") << "LIKE " << std::quoted(query.like, '\'');
|
||||
rewritten_query
|
||||
<< " WHERE name "
|
||||
<< (query.not_like ? "NOT " : "")
|
||||
<< (query.case_insensitive_like ? "ILIKE " : "LIKE ")
|
||||
<< std::quoted(query.like, '\'');
|
||||
}
|
||||
|
||||
if (query.limit_length)
|
||||
@ -54,7 +58,11 @@ String InterpreterShowTablesQuery::getRewrittenQuery()
|
||||
|
||||
if (!query.like.empty())
|
||||
{
|
||||
rewritten_query << " WHERE cluster " << (query.not_like ? "NOT " : "") << "LIKE " << std::quoted(query.like, '\'');
|
||||
rewritten_query
|
||||
<< " WHERE cluster "
|
||||
<< (query.not_like ? "NOT " : "")
|
||||
<< (query.case_insensitive_like ? "ILIKE " : "LIKE ")
|
||||
<< std::quoted(query.like, '\'');
|
||||
}
|
||||
|
||||
if (query.limit_length)
|
||||
@ -98,7 +106,11 @@ String InterpreterShowTablesQuery::getRewrittenQuery()
|
||||
rewritten_query << "database = " << std::quoted(database, '\'');
|
||||
|
||||
if (!query.like.empty())
|
||||
rewritten_query << " AND name " << (query.not_like ? "NOT " : "") << "LIKE " << std::quoted(query.like, '\'');
|
||||
rewritten_query
|
||||
<< " AND name "
|
||||
<< (query.not_like ? "NOT " : "")
|
||||
<< (query.case_insensitive_like ? "ILIKE " : "LIKE ")
|
||||
<< std::quoted(query.like, '\'');
|
||||
else if (query.where_expression)
|
||||
rewritten_query << " AND (" << query.where_expression << ")";
|
||||
|
||||
|
@ -13,43 +13,41 @@ ASTPtr ASTShowTablesQuery::clone() const
|
||||
return res;
|
||||
}
|
||||
|
||||
void ASTShowTablesQuery::formatLike(const FormatSettings & settings) const
|
||||
{
|
||||
if (!like.empty())
|
||||
settings.ostr
|
||||
<< (settings.hilite ? hilite_keyword : "")
|
||||
<< (not_like ? " NOT" : "")
|
||||
<< (case_insensitive_like ? " ILIKE " : " LIKE ")
|
||||
<< (settings.hilite ? hilite_none : "")
|
||||
<< std::quoted(like, '\'');
|
||||
}
|
||||
|
||||
void ASTShowTablesQuery::formatLimit(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||
{
|
||||
if (limit_length)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " LIMIT " << (settings.hilite ? hilite_none : "");
|
||||
limit_length->formatImpl(settings, state, frame);
|
||||
}
|
||||
}
|
||||
|
||||
void ASTShowTablesQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||
{
|
||||
if (databases)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW DATABASES" << (settings.hilite ? hilite_none : "");
|
||||
formatLike(settings);
|
||||
formatLimit(settings, state, frame);
|
||||
|
||||
if (!like.empty())
|
||||
settings.ostr
|
||||
<< (settings.hilite ? hilite_keyword : "")
|
||||
<< (not_like ? " NOT" : "")
|
||||
<< (case_insensitive_like ? " ILIKE " : " LIKE ")
|
||||
<< (settings.hilite ? hilite_none : "")
|
||||
<< std::quoted(like, '\'');
|
||||
|
||||
if (limit_length)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " LIMIT " << (settings.hilite ? hilite_none : "");
|
||||
limit_length->formatImpl(settings, state, frame);
|
||||
}
|
||||
}
|
||||
else if (clusters)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW CLUSTERS" << (settings.hilite ? hilite_none : "");
|
||||
formatLike(settings);
|
||||
formatLimit(settings, state, frame);
|
||||
|
||||
if (!like.empty())
|
||||
settings.ostr
|
||||
<< (settings.hilite ? hilite_keyword : "")
|
||||
<< (not_like ? " NOT" : "")
|
||||
<< (case_insensitive_like ? " ILIKE " : " LIKE ")
|
||||
<< (settings.hilite ? hilite_none : "")
|
||||
<< std::quoted(like, '\'');
|
||||
|
||||
if (limit_length)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " LIMIT " << (settings.hilite ? hilite_none : "");
|
||||
limit_length->formatImpl(settings, state, frame);
|
||||
}
|
||||
}
|
||||
else if (cluster)
|
||||
{
|
||||
@ -65,25 +63,15 @@ void ASTShowTablesQuery::formatQueryImpl(const FormatSettings & settings, Format
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FROM " << (settings.hilite ? hilite_none : "")
|
||||
<< backQuoteIfNeed(from);
|
||||
|
||||
if (!like.empty())
|
||||
settings.ostr
|
||||
<< (settings.hilite ? hilite_keyword : "")
|
||||
<< (not_like ? " NOT" : "")
|
||||
<< (case_insensitive_like ? " ILIKE " : " LIKE ")
|
||||
<< (settings.hilite ? hilite_none : "")
|
||||
<< std::quoted(like, '\'');
|
||||
formatLike(settings);
|
||||
|
||||
else if (where_expression)
|
||||
if (where_expression)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " WHERE " << (settings.hilite ? hilite_none : "");
|
||||
where_expression->formatImpl(settings, state, frame);
|
||||
}
|
||||
|
||||
if (limit_length)
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " LIMIT " << (settings.hilite ? hilite_none : "");
|
||||
limit_length->formatImpl(settings, state, frame);
|
||||
}
|
||||
formatLimit(settings, state, frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,8 @@ public:
|
||||
ASTPtr clone() const override;
|
||||
|
||||
protected:
|
||||
void formatLike(const FormatSettings & settings) const;
|
||||
void formatLimit(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const;
|
||||
void formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user