Skip to content

Commit

Permalink
Fixed number rows validation
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigoriyPA committed Oct 23, 2024
1 parent 21b4991 commit b274c81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ydb/core/fq/libs/row_dispatcher/json_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ class TJsonParser::TImpl {
}
rowId++;
}
if (rowId < Buffer.NumberValues) {
throw yexception() << "Failed to parse json messages, expected " << Buffer.NumberValues << " json rows but got " << rowId;
if (rowId != Buffer.NumberValues) {
throw yexception() << "Failed to parse json messages, expected " << Buffer.NumberValues << " json rows from offset " << Buffer.Offsets.front() << " but got " << rowId;
}

for (size_t i = 0; i < Columns.size(); ++i) {
Expand Down
3 changes: 2 additions & 1 deletion ydb/core/fq/libs/row_dispatcher/ut/json_parser_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,9 @@ Y_UNIT_TEST_SUITE(TJsonParserTests) {
}

Y_UNIT_TEST_F(ThrowExceptionByError, TFixture) {
MakeParser({"a2", "a1"});
MakeParser({"a"});
UNIT_ASSERT_EXCEPTION_CONTAINS(PushToParser(42, R"(ydb)"), simdjson::simdjson_error, "INCORRECT_TYPE: The JSON element does not have the requested type.");
UNIT_ASSERT_EXCEPTION_CONTAINS(PushToParser(42, R"({"a": "value1"} {"a": "value2"})"), yexception, "Failed to parse json messages, expected 1 json rows from offset 42 but got 2");
}
}

Expand Down

0 comments on commit b274c81

Please sign in to comment.