Skip to content

Commit e237ef2

Browse files
authored
[ML] Trap the case that no data are sent to data_frame_analyzer explicitly (#585)
1 parent 1635575 commit e237ef2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/api/CDataFrameAnalyzer.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ void CDataFrameAnalyzer::run() {
133133
<< ". Please report this problem.");
134134
return;
135135
}
136+
if (m_DataFrame->numberRows() == 0) {
137+
HANDLE_FATAL(<< "Input error: no data sent.");
138+
return;
139+
}
136140

137141
LOG_TRACE(<< "Running analysis...");
138142

lib/api/unittest/CDataFrameAnalyzerTest.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,18 @@ void CDataFrameAnalyzerTest::testErrors() {
729729
LOG_DEBUG(<< core::CContainerPrinter::print(errors));
730730
CPPUNIT_ASSERT(errors.size() > 0);
731731
}
732+
733+
// No data.
734+
{
735+
api::CDataFrameAnalyzer analyzer{outlierSpec(2), outputWriterFactory};
736+
errors.clear();
737+
CPPUNIT_ASSERT_EQUAL(
738+
true, analyzer.handleRecord({"c1", "c2", "c3", "c4", "c5", ".", "."},
739+
{"", "", "", "", "", "", "$"}));
740+
LOG_DEBUG(<< core::CContainerPrinter::print(errors));
741+
CPPUNIT_ASSERT(errors.size() > 0);
742+
CPPUNIT_ASSERT_EQUAL(std::string{"Input error: no data sent."}, errors[0]);
743+
}
732744
}
733745

734746
void CDataFrameAnalyzerTest::testRoundTripDocHashes() {

0 commit comments

Comments
 (0)