@@ -22,6 +22,9 @@ namespace duckdb {
2222
2323namespace {
2424
25+ // Indicates successful query.
26+ constexpr bool SUCCESS = true ;
27+
2528// Get database instance from expression state.
2629// Returned instance ownership lies in the given [`state`].
2730DatabaseInstance &GetDatabaseInstance (ExpressionState &state) {
@@ -76,7 +79,6 @@ void WrapFileSystem(const DataChunk &args, ExpressionState &state, Vector &resul
7679 ObservabilityFsRefRegistry::Get ().Register (observe_filesystem.get ());
7780 vfs.RegisterSubSystem (std::move (observe_filesystem));
7881
79- constexpr bool SUCCESS = true ;
8082 result.Reference (Value (SUCCESS));
8183}
8284
@@ -108,6 +110,11 @@ void ListRegisteredFileSystems(DataChunk &args, ExpressionState &state, Vector &
108110 FlatVector::SetValidity (result, ValidityMask (filesystems.size ()));
109111}
110112
113+ void ClearExternalFileCacheStatsRecord (DataChunk &args, ExpressionState &state, Vector &result) {
114+ GetExternalFileCacheStatsRecorder ().ClearCacheAccessRecord ();
115+ result.Reference (Value (SUCCESS));
116+ }
117+
111118// Extract or get httpfs filesystem.
112119unique_ptr<FileSystem> ExtractOrCreateHttpfs (FileSystem &vfs) {
113120 auto filesystems = vfs.ListSubSystems ();
@@ -228,6 +235,13 @@ void LoadInternal(ExtensionLoader &loader) {
228235 /* return_type=*/ LogicalTypeId::BOOLEAN, WrapFileSystem);
229236 loader.RegisterFunction (wrap_cache_filesystem_function);
230237
238+ // Register a function to clear external file cache stats record.
239+ ScalarFunction clear_external_file_cache_access_record_function (" observefs_clear_external_file_cache_access_record" ,
240+ /* arguments=*/ {},
241+ /* return_type=*/ LogicalTypeId::BOOLEAN,
242+ ClearExternalFileCacheStatsRecord);
243+ loader.RegisterFunction (clear_external_file_cache_access_record_function);
244+
231245 // Register external file cache access query function.
232246 loader.RegisterFunction (ExternalFileCacheAccessQueryFunc ());
233247}
0 commit comments