From d8ed4db6d4bf8c12273d7cfee4ef85e7c0058399 Mon Sep 17 00:00:00 2001 From: kssenii Date: Wed, 22 Dec 2021 11:42:23 +0300 Subject: [PATCH] Fix --- src/IO/ReadBufferFromS3.cpp | 3 ++- tests/integration/test_storage_s3/test.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/IO/ReadBufferFromS3.cpp b/src/IO/ReadBufferFromS3.cpp index 30484b14021..f01640cb95b 100644 --- a/src/IO/ReadBufferFromS3.cpp +++ b/src/IO/ReadBufferFromS3.cpp @@ -239,7 +239,8 @@ std::unique_ptr ReadBufferFromS3::initialize() } else { - req.SetRange(fmt::format("bytes={}-", offset)); + if (offset) + req.SetRange(fmt::format("bytes={}-", offset)); LOG_TEST(log, "Read S3 object. Bucket: {}, Key: {}, Offset: {}", bucket, key, offset); } diff --git a/tests/integration/test_storage_s3/test.py b/tests/integration/test_storage_s3/test.py index bfeda84fa21..67cda5c4edb 100644 --- a/tests/integration/test_storage_s3/test.py +++ b/tests/integration/test_storage_s3/test.py @@ -842,3 +842,18 @@ def test_seekable_formats_url(started_cluster): result = instance.query(f"SELECT formatReadableSize(memory_usage) FROM system.query_log WHERE startsWith(query, 'SELECT count() FROM url') AND memory_usage > 0 ORDER BY event_time desc") print(result[:3]) assert(int(result[:3]) < 200) + + +def test_empty_file(started_cluster): + bucket = started_cluster.minio_bucket + instance = started_cluster.instances["dummy"] + + name = "empty" + url = f'http://{started_cluster.minio_ip}:{MINIO_INTERNAL_PORT}/{bucket}/{name}' + + minio = started_cluster.minio_client + minio.put_object(bucket, name, io.BytesIO(b""), 0) + + table_function = f"s3('{url}', 'CSV', 'id Int32')" + result = instance.query(f"SELECT count() FROM {table_function}") + assert(int(result) == 0)