From f1ac0bd82107afa1ab9f61a3b818046b3ae09fc5 Mon Sep 17 00:00:00 2001 From: 4gl <@> Date: Tue, 28 Apr 2026 19:06:29 +0100 Subject: [PATCH] fix: removing usecache option (wasn't used in the end) --- tests/viyaonly/mfv_existsashdat.test.sas | 27 +----------------------- viya/mfv_existsashdat.sas | 18 ++++++---------- 2 files changed, 8 insertions(+), 37 deletions(-) diff --git a/tests/viyaonly/mfv_existsashdat.test.sas b/tests/viyaonly/mfv_existsashdat.test.sas index 1dd2426..1cf5dde 100644 --- a/tests/viyaonly/mfv_existsashdat.test.sas +++ b/tests/viyaonly/mfv_existsashdat.test.sas @@ -63,37 +63,12 @@ quit; ) /* ------------------------------------------------------------------------ */ -%put TEST 3 - usecache= controls whether the cached dataset is reused; +/* Teardown */ /* ------------------------------------------------------------------------ */ - -/* First call: populates the cache dataset work.testcache_&testcaslib */ -%let _rc=%mfv_existsashdat(&testcaslib..&tab1,outprefix=work.testcache); - -/* Delete the sashdat from the caslib so a fresh scan would return 0 */ proc casutil; deletesource casdata="&tab1..sashdat" incaslib="&testcaslib" quiet; quit; -/* usecache=1 (default): must return 1 from the cached dataset */ -%mp_assert( - iftrue=(%mfv_existsashdat(&testcaslib..&tab1,outprefix=work.testcache)=1), - desc=Check returns 1 from cache even after source file is deleted -) - -/* usecache=0: forces rescan and reflects the deletion */ -%mp_assert( - iftrue=( - %mfv_existsashdat(&testcaslib..&tab1,usecache=0,outprefix=work.testcache)=0 - ), - desc=Check returns 0 when usecache=0 forces a rescan after source file deleted -) - -%let syscc=0; - - -/* ------------------------------------------------------------------------ */ -/* Teardown: terminate CAS session (sashdat already removed in TEST 4) */ -/* ------------------------------------------------------------------------ */ cas mysess terminate; %let syscc=0; diff --git a/viya/mfv_existsashdat.sas b/viya/mfv_existsashdat.sas index 84d47cd..65be9e3 100644 --- a/viya/mfv_existsashdat.sas +++ b/viya/mfv_existsashdat.sas @@ -8,15 +8,12 @@ The function uses `dosubl()` to run the `table.fileinfo` action, for the specified library, filtering for `*.sashdat` tables. - IMPORTANT NOTE - The results are cached in a WORK table (&outprefix._&lib). - If that table already exists, it is queried instead, to avoid the - dosubl() performance hit. - - To force a rescan, just use a new `&outprefix` value, or delete the table(s) - before running the function. + Results are cached in a WORK table (&outprefix._&lib). If that table + already exists it is queried directly to avoid the dosubl() overhead. + To force a rescan, use a new `&outprefix` value or delete the cache + table before calling. @param [in] libds library.dataset - @param [in] usecache= (1) Set to 0 to rebuild the cache @param [out] outprefix= (work.mfv_existsashdat) Used to store current HDATA tables to improve subsequent query performance. This reference is a prefix and is converted to `&prefix._{libref}` @@ -27,14 +24,13 @@ @author Mathieu Blauw **/ -%macro mfv_existsashdat(libds,usecache=1,outprefix=work.mfv_existsashdat -); +%macro mfv_existsashdat(libds,outprefix=work.mfv_existsashdat); %local rc dsid name lib ds; %let lib=%upcase(%scan(&libds,1,'.')); %let ds=%upcase(%scan(&libds,-1,'.')); -/* if table does not exist, create it */ -%if &usecache ne 1 or %sysfunc(exist(&outprefix._&lib)) ne 1 %then %do; +/* if cache table does not exist, build it */ +%if %sysfunc(exist(&outprefix._&lib)) ne 1 %then %do; %let rc=%sysfunc(dosubl(%nrstr( /* Read in table list (once per &lib per session) */ proc cas;