Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Null format for tcp handler. #7606

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion dbms/programs/server/TCPHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ void TCPHandler::processOrdinaryQuery()
sendLogs();
}

sendData(block);
if (!block || !state.io.null_format)
sendData(block);
if (!block)
break;
}
Expand Down
3 changes: 3 additions & 0 deletions dbms/src/DataStreams/BlockIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ struct BlockIO
std::function<void(IBlockInputStream *, IBlockOutputStream *)> finish_callback;
std::function<void()> exception_callback;

/// When it is true, don't bother sending any non-empty blocks to the out stream
bool null_format = false;

/// Call these functions if you want to log the request.
void onFinish()
{
Expand Down
11 changes: 10 additions & 1 deletion dbms/src/Interpreters/executeQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,18 @@ BlockIO executeQuery(
bool may_have_embedded_data,
bool allow_processors)
{
ASTPtr ast;
BlockIO streams;
std::tie(std::ignore, streams) = executeQueryImpl(query.data(), query.data() + query.size(), context,
std::tie(ast, streams) = executeQueryImpl(query.data(), query.data() + query.size(), context,
internal, stage, !may_have_embedded_data, nullptr, allow_processors);
if (streams.in)
{
const auto * ast_query_with_output = dynamic_cast<const ASTQueryWithOutput *>(ast.get());
String format_name = ast_query_with_output && (ast_query_with_output->format != nullptr)
? getIdentifierName(ast_query_with_output->format) : context.getDefaultFormat();
if (format_name == "Null")
streams.null_format = true;
}
return streams;
}

Expand Down