mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Better fix
This commit is contained in:
parent
9cf7247bcc
commit
3da0b2573a
@ -130,11 +130,6 @@ void applySettingsOverridesForLocal(ContextMutablePtr context)
|
||||
context->setSettings(settings);
|
||||
}
|
||||
|
||||
LocalServer::LocalServer()
|
||||
{
|
||||
is_local = true;
|
||||
}
|
||||
|
||||
Poco::Util::LayeredConfiguration & LocalServer::getClientConfiguration()
|
||||
{
|
||||
return config();
|
||||
|
@ -23,7 +23,7 @@ namespace DB
|
||||
class LocalServer : public ClientApplicationBase, public Loggers
|
||||
{
|
||||
public:
|
||||
LocalServer();
|
||||
LocalServer() = default;
|
||||
|
||||
void initialize(Poco::Util::Application & self) override;
|
||||
|
||||
|
@ -1630,6 +1630,11 @@ void ClientBase::sendData(Block & sample, const ColumnsDescription & columns_des
|
||||
if (!parsed_insert_query)
|
||||
return;
|
||||
|
||||
/// If it's clickhouse-local, and the input data reading is already baked into the query pipeline,
|
||||
/// don't read the data again here.
|
||||
if (!connection->isSendDataNeeded())
|
||||
return;
|
||||
|
||||
bool have_data_in_stdin = !is_interactive && !stdin_is_a_tty && isStdinNotEmptyAndValid(std_in);
|
||||
|
||||
if (need_render_progress)
|
||||
@ -1748,7 +1753,6 @@ void ClientBase::sendData(Block & sample, const ColumnsDescription & columns_des
|
||||
}
|
||||
else if (!is_interactive)
|
||||
{
|
||||
if (!is_local)
|
||||
sendDataFromStdin(sample, columns_description_for_query, parsed_query);
|
||||
}
|
||||
else
|
||||
|
@ -263,8 +263,6 @@ protected:
|
||||
bool is_interactive = false; /// Use either interactive line editing interface or batch mode.
|
||||
bool delayed_interactive = false;
|
||||
|
||||
bool is_local = false; /// clickhouse-local, otherwise clickhouse-client
|
||||
|
||||
bool echo_queries = false; /// Print queries before execution in batch mode.
|
||||
bool ignore_error = false; /// In case of errors, don't print error message, continue to next query. Only applicable for non-interactive mode.
|
||||
|
||||
|
@ -109,6 +109,10 @@ public:
|
||||
/// Send block of data; if name is specified, server will write it to external (temporary) table of that name.
|
||||
virtual void sendData(const Block & block, const String & name, bool scalar) = 0;
|
||||
|
||||
/// Whether the client needs to read and send the data for the INSERT.
|
||||
/// False if the server will read the data through other means (in particular if clickhouse-local added input reading step directly into the query pipeline).
|
||||
virtual bool isSendDataNeeded() const { return true; }
|
||||
|
||||
/// Send all contents of external (temporary) tables.
|
||||
virtual void sendExternalTablesData(ExternalTablesData & data) = 0;
|
||||
|
||||
|
@ -328,6 +328,11 @@ void LocalConnection::sendData(const Block & block, const String &, bool)
|
||||
sendProfileEvents();
|
||||
}
|
||||
|
||||
bool LocalConnection::isSendDataNeeded() const
|
||||
{
|
||||
return !state || state->input_pipeline == nullptr;
|
||||
}
|
||||
|
||||
void LocalConnection::sendCancel()
|
||||
{
|
||||
state->is_cancelled = true;
|
||||
|
@ -120,6 +120,8 @@ public:
|
||||
|
||||
void sendData(const Block & block, const String & name/* = "" */, bool scalar/* = false */) override;
|
||||
|
||||
bool isSendDataNeeded() const override;
|
||||
|
||||
void sendExternalTablesData(ExternalTablesData &) override;
|
||||
|
||||
void sendMergeTreeReadTaskResponse(const ParallelReadResponse & response) override;
|
||||
|
@ -9,3 +9,7 @@ bar
|
||||
bam
|
||||
# inferred destination table structure
|
||||
foo
|
||||
# direct
|
||||
foo
|
||||
# infile
|
||||
foo
|
||||
|
@ -32,4 +32,12 @@ echo '# inferred destination table structure'
|
||||
$CLICKHOUSE_LOCAL --engine_file_truncate_on_insert=1 -q "insert into function file('$tmp_file', 'TSV') select * from input('x String') format LineAsString" <"$tmp_input"
|
||||
cat "$tmp_file"
|
||||
|
||||
echo '# direct'
|
||||
$CLICKHOUSE_LOCAL --engine_file_truncate_on_insert=1 -q "insert into function file('$tmp_file', 'LineAsString', 'x String') format LineAsString" <"$tmp_input"
|
||||
cat "$tmp_file"
|
||||
|
||||
echo '# infile'
|
||||
$CLICKHOUSE_LOCAL --engine_file_truncate_on_insert=1 -q "insert into function file('$tmp_file', 'LineAsString', 'x String') from infile '$tmp_input' format LineAsString"
|
||||
cat "$tmp_file"
|
||||
|
||||
rm -f "${tmp_file:?}" "${tmp_input:?}"
|
||||
|
Loading…
Reference in New Issue
Block a user