diff --git a/src/Storages/StorageFile.cpp b/src/Storages/StorageFile.cpp index 558216a6216a7f7d23f5c498e1c300d0453ed35f..9e60d5bad15e6c057275448fa483fcbe02468086 100644 --- a/src/Storages/StorageFile.cpp +++ b/src/Storages/StorageFile.cpp @@ -502,8 +502,12 @@ BlockOutputStreamPtr StorageFile::write( if (format_name == "Distributed") throw Exception("Method write is not implemented for Distributed format", ErrorCodes::NOT_IMPLEMENTED); + std::string path; + if (!paths.empty()) + path = paths[0]; + return std::make_shared(*this, metadata_snapshot, - chooseCompressionMethod(paths[0], compression_method), context); + chooseCompressionMethod(path, compression_method), context); } Strings StorageFile::getDataPaths() const diff --git a/tests/queries/0_stateless/01500_StorageFile_write_to_fd.reference b/tests/queries/0_stateless/01500_StorageFile_write_to_fd.reference new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/queries/0_stateless/01500_StorageFile_write_to_fd.sh b/tests/queries/0_stateless/01500_StorageFile_write_to_fd.sh new file mode 100755 index 0000000000000000000000000000000000000000..589a578eb0b05badc8cf921f1dbf097a8f95fbe9 --- /dev/null +++ b/tests/queries/0_stateless/01500_StorageFile_write_to_fd.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + +# The following command will execute: +# CREATE TABLE table (key UInt32) ENGINE = File(TSV, stdin); +# INSERT INTO `table` SELECT key FROM input('key UInt32') FORMAT TSV +${CLICKHOUSE_LOCAL} -S 'key UInt32' -q "INSERT INTO \`table\` SELECT key FROM input('key UInt32') FORMAT TSV" < /dev/null