diff --git a/src/Core/ExternalTable.cpp b/src/Core/ExternalTable.cpp index f8bbd16d038..bc72c996384 100644 --- a/src/Core/ExternalTable.cpp +++ b/src/Core/ExternalTable.cpp @@ -106,6 +106,9 @@ void BaseExternalTable::parseStructureFromTypesField(const std::string & argumen void BaseExternalTable::initSampleBlock() { + if (sample_block) + return; + const DataTypeFactory & data_type_factory = DataTypeFactory::instance(); for (const auto & elem : structure) diff --git a/tests/queries/0_stateless/03140_client_subsequent_external_tables.reference b/tests/queries/0_stateless/03140_client_subsequent_external_tables.reference new file mode 100644 index 00000000000..0d55bed3a35 --- /dev/null +++ b/tests/queries/0_stateless/03140_client_subsequent_external_tables.reference @@ -0,0 +1,2 @@ +foo +foo diff --git a/tests/queries/0_stateless/03140_client_subsequent_external_tables.sh b/tests/queries/0_stateless/03140_client_subsequent_external_tables.sh new file mode 100755 index 00000000000..af75bf42172 --- /dev/null +++ b/tests/queries/0_stateless/03140_client_subsequent_external_tables.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +INPUT_FILE=$CUR_DIR/$CLICKHOUSE_DATABASE.tsv +echo "foo" > "$INPUT_FILE" + +$CLICKHOUSE_CLIENT --external --file="$INPUT_FILE" --name=t --structure='x String' -nm -q " +select * from t; +select * from t; +" + +rm "${INPUT_FILE:?}"