diff --git a/tree/dataframe/src/RDFSnapshotHelpers.cxx b/tree/dataframe/src/RDFSnapshotHelpers.cxx index 3764a447627ca..0b517b735fac2 100644 --- a/tree/dataframe/src/RDFSnapshotHelpers.cxx +++ b/tree/dataframe/src/RDFSnapshotHelpers.cxx @@ -971,8 +971,13 @@ void ROOT::Internal::RDF::UntypedSnapshotRNTupleHelper::Finalize() fFillContexts.clear(); // Then destroy the RNTupleParallelWriter and write the metadata. fWriter.reset(); + // Finally, close the output TFile to ensure it's properly written to disk. We don't destroy it to avoid triggering + // a warning about the lazy Snapshot not being triggered + fOutputFile->Close(); + // We can now set the data source of the loop manager for the RDataFrame that is returned by the Snapshot call. - fOutputLoopManager->SetDataSource(std::make_unique(fDirName + "/" + fNTupleName, fFileName)); + const auto fullNTupleName = fDirName.empty() ? fNTupleName : fDirName + '/' + fNTupleName; + fOutputLoopManager->SetDataSource(std::make_unique(fullNTupleName, fFileName)); } /**