2023-03-26 14:36:38 +00:00
# include <Parsers/ASTShowColumnsQuery.h>
# include <iomanip>
# include <Common/quoteString.h>
# include <IO/Operators.h>
namespace DB
{
ASTPtr ASTShowColumnsQuery : : clone ( ) const
{
auto res = std : : make_shared < ASTShowColumnsQuery > ( * this ) ;
res - > children . clear ( ) ;
cloneOutputOptions ( * res ) ;
return res ;
}
void ASTShowColumnsQuery : : formatQueryImpl ( const FormatSettings & settings , FormatState & state , FormatStateStacked frame ) const
{
settings . ostr < < ( settings . hilite ? hilite_keyword : " " )
< < " SHOW "
< < ( extended ? " EXTENDED " : " " )
< < ( full ? " FULL " : " " )
< < " COLUMNS "
< < ( settings . hilite ? hilite_none : " " ) ;
if ( from_database . empty ( ) )
settings . ostr < < ( settings . hilite ? hilite_keyword : " " ) < < " FROM " < < ( settings . hilite ? hilite_none : " " ) < < backQuoteIfNeed ( from_table ) ;
else
settings . ostr < < ( settings . hilite ? hilite_keyword : " " ) < < " FROM " < < ( settings . hilite ? hilite_none : " " ) < < backQuoteIfNeed ( from_database ) < < " . " < < backQuoteIfNeed ( from_table ) ;
if ( ! like . empty ( ) )
settings . ostr < < ( settings . hilite ? hilite_keyword : " " )
2023-03-28 20:07:26 +00:00
< < ( not_like ? " NOT " : " " )
2023-03-26 14:36:38 +00:00
< < ( case_insensitive_like ? " ILIKE " : " LIKE " )
< < ( settings . hilite ? hilite_none : " " )
< < DB : : quote < < like ;
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 ) ;
}
}
}