Skip to content

Commit d470edd

Browse files
authored
YQ-3460 fix error attempt to read after eof (ydb-platform#7942)
1 parent 178fd7e commit d470edd

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

ydb/core/external_sources/object_storage/inference/arrow_inferencinator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <ydb/library/actors/core/actor_bootstrapped.h>
1010
#include <ydb/library/actors/core/hfunc.h>
1111
#include <ydb/library/actors/core/log.h>
12+
#include <ydb/library/services/services.pb.h>
1213
#include <ydb/public/api/protos/ydb_value.pb.h>
1314

1415
#define LOG_E(name, stream) \

ydb/core/external_sources/object_storage/inference/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ PEERDIR(
1616

1717
ydb/core/external_sources/object_storage
1818

19+
ydb/library/services
1920
ydb/library/yql/providers/s3/compressors
2021
)
2122

ydb/core/kqp/ut/federated_query/s3/kqp_federated_query_ut.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,47 @@ Y_UNIT_TEST_SUITE(KqpFederatedQuery) {
17911791
Y_UNIT_TEST(ExecuteScriptWithThinFile) {
17921792
ExecuteSelectQuery("test_bucket_execute_script_with_large_file", 5_MB, 500000);
17931793
}
1794+
1795+
Y_UNIT_TEST(TestReadEmptyFileWithCsvFormat) {
1796+
const TString externalDataSourceName = "/Root/external_data_source";
1797+
const TString bucket = "test_bucket1";
1798+
1799+
CreateBucketWithObject(bucket, "test_object", "");
1800+
1801+
auto kikimr = MakeKikimrRunner(NYql::IHTTPGateway::Make());
1802+
1803+
auto tc = kikimr->GetTableClient();
1804+
auto session = tc.CreateSession().GetValueSync().GetSession();
1805+
const TString query = fmt::format(R"(
1806+
CREATE EXTERNAL DATA SOURCE `{external_source}` WITH (
1807+
SOURCE_TYPE="ObjectStorage",
1808+
LOCATION="{location}",
1809+
AUTH_METHOD="NONE"
1810+
);)",
1811+
"external_source"_a = externalDataSourceName,
1812+
"location"_a = GetBucketLocation(bucket)
1813+
);
1814+
auto result = session.ExecuteSchemeQuery(query).GetValueSync();
1815+
UNIT_ASSERT_C(result.GetStatus() == NYdb::EStatus::SUCCESS, result.GetIssues().ToString());
1816+
1817+
const TString sql = fmt::format(R"(
1818+
SELECT * FROM `{external_source}`.`/`
1819+
WITH (
1820+
SCHEMA = (
1821+
data String
1822+
),
1823+
FORMAT = "csv_with_names"
1824+
)
1825+
)", "external_source"_a=externalDataSourceName);
1826+
1827+
auto db = kikimr->GetQueryClient();
1828+
auto scriptExecutionOperation = db.ExecuteScript(sql).ExtractValueSync();
1829+
UNIT_ASSERT_VALUES_EQUAL_C(scriptExecutionOperation.Status().GetStatus(), EStatus::SUCCESS, scriptExecutionOperation.Status().GetIssues().ToString());
1830+
UNIT_ASSERT(scriptExecutionOperation.Metadata().ExecutionId);
1831+
1832+
NYdb::NQuery::TScriptExecutionOperation readyOp = WaitScriptExecutionOperation(scriptExecutionOperation.Id(), kikimr->GetDriver());
1833+
UNIT_ASSERT_EQUAL_C(readyOp.Metadata().ExecStatus, EExecStatus::Completed, readyOp.Status().GetIssues().ToString());
1834+
}
17941835
}
17951836

17961837
} // namespace NKikimr::NKqp

ydb/library/yql/udfs/common/clickhouse/client/src/IO/ReadHelpers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,9 @@ void readBackQuotedStringWithSQLStyle(String & s, ReadBuffer & buf)
617617
template <typename Vector>
618618
void readCSVStringInto(Vector & s, ReadBuffer & buf, const FormatSettings::CSV & settings)
619619
{
620+
/// Empty string
620621
if (buf.eof())
621-
throwReadAfterEOF();
622+
return;
622623

623624
const char delimiter = settings.delimiter;
624625
const char maybe_quote = *buf.position();

0 commit comments

Comments
 (0)