Fix 'Unknown executor' when reading from stdin in clickhouse local

This commit is contained in:
Michael Kolupaev 2024-10-25 06:12:50 +00:00
parent 2e61f2bb99
commit e19bf218f6
6 changed files with 27 additions and 6 deletions

View File

@ -130,6 +130,11 @@ void applySettingsOverridesForLocal(ContextMutablePtr context)
context->setSettings(settings);
}
LocalServer::LocalServer()
{
is_local = true;
}
Poco::Util::LayeredConfiguration & LocalServer::getClientConfiguration()
{
return config();

View File

@ -23,7 +23,7 @@ namespace DB
class LocalServer : public ClientApplicationBase, public Loggers
{
public:
LocalServer() = default;
LocalServer();
void initialize(Poco::Util::Application & self) override;

View File

@ -1748,7 +1748,8 @@ void ClientBase::sendData(Block & sample, const ColumnsDescription & columns_des
}
else if (!is_interactive)
{
sendDataFromStdin(sample, columns_description_for_query, parsed_query);
if (!is_local)
sendDataFromStdin(sample, columns_description_for_query, parsed_query);
}
else
throw Exception(ErrorCodes::NO_DATA_TO_INSERT, "No data to insert");

View File

@ -263,6 +263,8 @@ 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.

View File

@ -1,4 +1,6 @@
# foo
# foo (pipe)
foo
# foo (file)
foo
# !foo
# bar

View File

@ -4,17 +4,28 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
tmp_file="$CUR_DIR/$CLICKHOUSE_DATABASE.txt"
echo '# foo'
tmp_file="$CUR_DIR/03031_$CLICKHOUSE_DATABASE.txt"
tmp_input="$CUR_DIR/03031_${CLICKHOUSE_DATABASE}_in.txt"
echo '# foo (pipe)'
$CLICKHOUSE_LOCAL --engine_file_truncate_on_insert=1 -q "insert into function file('$tmp_file', 'LineAsString', 'x String') select * from input('x String') format LineAsString" <<<foo
cat "$tmp_file"
echo '# foo (file)'
echo 'foo' > "$tmp_input"
$CLICKHOUSE_LOCAL --engine_file_truncate_on_insert=1 -q "insert into function file('$tmp_file', 'LineAsString', 'x String') select * from input('x String') format LineAsString" <"$tmp_input"
cat "$tmp_file"
echo '# !foo'
$CLICKHOUSE_LOCAL --engine_file_truncate_on_insert=1 -q "insert into function file('$tmp_file', 'LineAsString', 'x String') select * from input('x String') where x != 'foo' format LineAsString" <<<foo
cat "$tmp_file"
echo '# bar'
$CLICKHOUSE_LOCAL --engine_file_truncate_on_insert=1 -q "insert into function file('$tmp_file', 'LineAsString', 'x String') select y from input('x String, y String') format TSV" <<<$'foo\tbar'
cat "$tmp_file"
echo '# defaults'
$CLICKHOUSE_LOCAL --input_format_tsv_empty_as_default=1 --engine_file_truncate_on_insert=1 -q "insert into function file('$tmp_file', 'LineAsString', 'x String') select y from input('x String, y String DEFAULT \\'bam\\'') format TSV" <<<$'foo\t'
cat "$tmp_file"
rm -f "${tmp_file:?}"
rm -f "${tmp_file:?}" "${tmp_input:?}"