diff --git a/tree/dataframe/src/RLoopManager.cxx b/tree/dataframe/src/RLoopManager.cxx index 1e3859b7fd083..f0fae786055c6 100644 --- a/tree/dataframe/src/RLoopManager.cxx +++ b/tree/dataframe/src/RLoopManager.cxx @@ -1233,6 +1233,8 @@ std::shared_ptr ROOT::Detail::RDF::CreateLMFromTTree(std::string_view datasetName, const std::vector &fileNameGlobs, const std::vector &defaultColumns, bool checkFile) { + if (fileNameGlobs.size() == 0) + throw std::invalid_argument("RDataFrame: empty list of input files."); // Introduce the same behaviour as in CreateLMFromFile for consistency. // Creating an RDataFrame with a non-existing file will throw early rather // than wait for the start of the graph execution. @@ -1288,6 +1290,9 @@ ROOT::Detail::RDF::CreateLMFromFile(std::string_view datasetName, const std::vec const ROOT::RDF::ColumnNames_t &defaultColumns) { + if (fileNameGlobs.size() == 0) + throw std::invalid_argument("RDataFrame: empty list of input files."); + auto inFile = OpenFileWithSanityChecks(fileNameGlobs[0]); if (inFile->Get(datasetName.data())) { diff --git a/tree/dataframe/test/dataframe_regression.cxx b/tree/dataframe/test/dataframe_regression.cxx index de2b22236c494..323e21895f931 100644 --- a/tree/dataframe/test/dataframe_regression.cxx +++ b/tree/dataframe/test/dataframe_regression.cxx @@ -321,6 +321,16 @@ TEST_P(RDFRegressionTests, FileNameQueryNoExt) EXPECT_EQ(df.Count().GetValue(), 10); } +TEST_P(RDFRegressionTests, EmptyFileList) +{ + try { + ROOT::RDataFrame df{"", {}}; + } catch (const std::invalid_argument &e) { + const std::string expected{"RDataFrame: empty list of input files."}; + EXPECT_EQ(e.what(), expected); + } +} + // run single-thread tests INSTANTIATE_TEST_SUITE_P(Seq, RDFRegressionTests, ::testing::Values(false));