mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 02:52:13 +00:00
Fix subsequent use of external tables in client
Before this patch it fails on the second and all other invocations: $ chc --external --file=/tmp/test-no-lf.tsv --name=t --structure='x String' azat.local$ select * from t limit 1 ┌─x───┐ 1. │ foo │ └─────┘ azat.local$ select * from t limit 1 Exception on client: Code: 27. DB::Exception: Cannot parse input: expected '\t' at end of stream.: (at row 1) : Buffer has gone, cannot extract information about what has been parsed.: (in file/uri /tmp/test-no-lf.tsv): While executing TabSeparatedRowInputFormat. (CANNOT_PARSE_INPUT_ASSERTION_FAILED) Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
437621cbe5
commit
119e000873
@ -106,6 +106,9 @@ void BaseExternalTable::parseStructureFromTypesField(const std::string & argumen
|
|||||||
|
|
||||||
void BaseExternalTable::initSampleBlock()
|
void BaseExternalTable::initSampleBlock()
|
||||||
{
|
{
|
||||||
|
if (sample_block)
|
||||||
|
return;
|
||||||
|
|
||||||
const DataTypeFactory & data_type_factory = DataTypeFactory::instance();
|
const DataTypeFactory & data_type_factory = DataTypeFactory::instance();
|
||||||
|
|
||||||
for (const auto & elem : structure)
|
for (const auto & elem : structure)
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
foo
|
||||||
|
foo
|
15
tests/queries/0_stateless/03140_client_subsequent_external_tables.sh
Executable file
15
tests/queries/0_stateless/03140_client_subsequent_external_tables.sh
Executable file
@ -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:?}"
|
Loading…
Reference in New Issue
Block a user