Skip to content

Commit de4cf13

Browse files
authored
YQ RD fixed format handler unit tests (#17538)
1 parent 8404d71 commit de4cf13

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

ydb/core/fq/libs/row_dispatcher/format_handler/parsers/parser_base.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ void TTopicParserBase::ParseBuffer() {
9595
Consumer->OnParsingError(status);
9696
}
9797
} catch (...) {
98-
Consumer->OnParsingError(TStatus::Fail(EStatusId::INTERNAL_ERROR, TStringBuilder() << "Failed to parse messages from offset " << GetOffsets().front() << ", got unexpected exception: " << CurrentExceptionMessage()));
98+
auto error = TStringBuilder() << "Failed to parse messages";
99+
if (const auto& offsets = GetOffsets()) {
100+
error << " from offset " << offsets.front();
101+
}
102+
error << ", got unexpected exception: " << CurrentExceptionMessage();
103+
Consumer->OnParsingError(TStatus::Fail(EStatusId::INTERNAL_ERROR, error));
99104
}
100105
Stats.AddParseAndFilterLatency(TInstant::Now() - startParseAndFilter);
101106
}

ydb/core/fq/libs/row_dispatcher/format_handler/ut/topic_parser_ut.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ Y_UNIT_TEST_SUITE(TestJsonParser) {
402402
CheckSuccess(MakeParser({{"a1", "[OptionalType; [DataType; Json]]"}, {"a2", "[OptionalType; [DataType; String]]"}}));
403403
CheckColumnError(R"({"a1": {"key": "value"}, "a2": {"key2": "value2"}})", 1, EStatusId::PRECONDITION_FAILED, TStringBuilder() << "Failed to parse json string at offset " << FIRST_OFFSET << ", got parsing error for column 'a2' with type [OptionalType; [DataType; String]] subissue: { <main>: Error: Found unexpected nested value (raw: '{\"key2\": \"value2\"}'), expected data type String, please use Json type for nested values }");
404404
CheckColumnError(R"({"a1": {"key": "value", "nested": {"a": "b", "c":}}, "a2": "str"})", 0, EStatusId::BAD_REQUEST, TStringBuilder() << "Failed to parse json string at offset " << FIRST_OFFSET + 1 << ", got parsing error for column 'a1' with type [OptionalType; [DataType; Json]] subissue: { <main>: Error: Found bad json value: '{\"key\": \"value\", \"nested\": {\"a\": \"b\", \"c\":}}' }");
405-
CheckColumnError(R"({"a1": {"key" "value"}, "a2": "str"})", 0, EStatusId::BAD_REQUEST, TStringBuilder() << "Failed to parse json string at offset " << FIRST_OFFSET + 2 << ", got parsing error for column 'a1' with type [OptionalType; [DataType; Json]] subissue: { <main>: Error: Failed to extract json value, current token: '{', error: TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. }");
405+
CheckColumnError(R"({"a1": {"key" "value"}, "a2": "str"})", 0, EStatusId::BAD_REQUEST, TStringBuilder() << "Failed to parse json string at offset " << FIRST_OFFSET + 2 << ", got parsing error for column 'a1' with type [OptionalType; [DataType; Json]] subissue: { <main>: Error: Failed to extract json value, current token: '{', error: TAPE_ERROR: The JSON document has an improper structure");
406406
}
407407

408408
Y_UNIT_TEST_F(BoolsValidation, TJsonParserFixture) {
@@ -413,8 +413,8 @@ Y_UNIT_TEST_SUITE(TestJsonParser) {
413413

414414
Y_UNIT_TEST_F(JsonStructureValidation, TJsonParserFixture) {
415415
CheckSuccess(MakeParser({{"a1", "[OptionalType; [DataType; String]]"}}));
416-
CheckColumnError(R"({"a1": Yelse})", 0, EStatusId::BAD_REQUEST, TStringBuilder() << "Failed to parse json string at offset " << FIRST_OFFSET << ", got parsing error for column 'a1' with type [OptionalType; [DataType; String]] subissue: { <main>: Error: Failed to determine json value type, current token: 'Yelse', error: TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. }");
417-
CheckBatchError(R"({"a1": "st""r"})", EStatusId::BAD_REQUEST, TStringBuilder() << "Failed to parse json message for offset " << FIRST_OFFSET + 1 << ", json item was corrupted: TAPE_ERROR: The JSON document has an improper structure: missing or superfluous commas, braces, missing keys, etc. Current data batch: {\"a1\": \"st\"\"r\"}");
416+
CheckColumnError(R"({"a1": Yelse})", 0, EStatusId::BAD_REQUEST, TStringBuilder() << "Failed to parse json string at offset " << FIRST_OFFSET << ", got parsing error for column 'a1' with type [OptionalType; [DataType; String]] subissue: { <main>: Error: Failed to determine json value type, current token: 'Yelse', error: TAPE_ERROR: The JSON document has an improper structure");
417+
CheckBatchError(R"({"a1": "st""r"})", EStatusId::BAD_REQUEST, TStringBuilder() << "Failed to parse json message for offset " << FIRST_OFFSET + 1 << ", json item was corrupted: TAPE_ERROR: The JSON document has an improper structure");
418418
CheckBatchError(R"({"a1": "x"} {"a1": "y"})", EStatusId::INTERNAL_ERROR, TStringBuilder() << "Failed to parse json messages, expected 1 json rows from offset " << FIRST_OFFSET + 2 << " but got 2 (expected one json row for each offset from topic API in json each row format, maybe initial data was corrupted or messages is not in json format), current data batch: {\"a1\": \"x\"} {\"a1\": \"y\"}");
419419
CheckBatchError(R"({)", EStatusId::INTERNAL_ERROR, TStringBuilder() << "Failed to parse json messages, expected 1 json rows from offset " << FIRST_OFFSET + 3 << " but got 0 (expected one json row for each offset from topic API in json each row format, maybe initial data was corrupted or messages is not in json format), current data batch: {");
420420
}

0 commit comments

Comments
 (0)