fix: showing catalog_cnt in libinfo
All checks were successful
Build / Build-and-ng-test (pull_request) Successful in 4m19s
Build / Build-and-test-development (pull_request) Successful in 8m53s

Closes #160
This commit is contained in:
allan
2025-06-11 10:06:52 +01:00
parent efb5ffa906
commit e44a25dcc3
8 changed files with 110 additions and 91 deletions

View File

@@ -14,5 +14,6 @@ create table &curlib..mpe_datastatus_libs(
libref char(8) label='Library Name',
libsize num format=SIZEKMG. label='Size of file',
table_cnt num label='Number of Tables',
catalog_cnt num label='Number of Catalogs',
constraint pk_mpe_datastatus_libs
primary key(libref,tx_to));

View File

@@ -29,7 +29,7 @@ create table dc.mpe_datacatalog_TABS(
nvar num label='Number of Variables',
compress char(8) label='Compression Routine',
pk_fields char(512)
label='Primary Key Fields (identified by being in a constraint that is both Unique and Not Null)',
label='Primary Key Fields (in a constraint that is both Unique and Not Null)',
constraint pk
primary key(libref,dsn,tx_to));

View File

@@ -2,7 +2,7 @@
@file
@brief migration script to move from v6.8.2 to v7.0 of data controller
BREAKING CHANGE - 4 additional tables for capturing catalog information
BREAKING CHANGE - 1 new column and 4 additional tables for capturing catalogs
Be sure to run this using the correct system account
(eg the regular DC account)
@@ -23,6 +23,9 @@
libname &dclib "/YOUR/DATACONTROLLER/LIBRARY/PATH";
proc sql;
create table work.BACKUP as select * from &dclib..mpe_datastatus_libs;
alter table &dclib..mpe_datastatus_libs add catalog_cnt num;
create table &dclib..mpe_datacatalog_CATS(
TX_FROM float format=datetime19.,
TX_TO float format=datetime19.,

View File

@@ -220,7 +220,8 @@ create table &lib..mpe_datastatus_libs(
TX_TO num &notnull format=datetime19.3,
libref char(8) label='Library Name',
libsize num format=SIZEKMG. label='Size of library',
table_cnt num label='Number of Tables'
table_cnt num label='Number of Tables',
catalog_cnt num label='Number of Catalogs'
);quit;
proc datasets lib=&lib noprint;
modify mpe_datastatus_libs;

View File

@@ -314,12 +314,23 @@ proc sql;
%if &ds = #ALL %then %do;
proc sql;
create table statuslibs as select
create table work.sumcat as
select libname as libref,
count(distinct memname) as catalog_cnt
from dictionary.catalogs
where upcase(libname)="&lib"
group by 1;
create table work.sumdsn as select
libref
,sum(filesize) as libsize
,count(*) as table_cnt
from statustabs
group by 1;
create table work.statuslibs as
select a.*, b.catalog_cnt
from work.sumdsn a
full join work.sumcat b
on a.libref=b.libref;
%bitemporal_dataloader(base_lib=&mpelib
,base_dsn=mpe_datastatus_libs

View File

@@ -32,7 +32,8 @@ create table work.libinfo as
a.schemas,
a.libid,
b.libsize,
b.table_cnt
b.table_cnt,
b.catalog_cnt
from &mpelib..mpe_datacatalog_libs(where=(&dc_dttmtfmt. lt tx_to)) a
left join &mpelib..mpe_datastatus_libs(where=(&dc_dttmtfmt. lt tx_to)) b
on a.libref=b.libref

View File

@@ -1,85 +1,86 @@
/**
@file refreshlibinfo.sas
@brief Refresh the Data Catalog for a particular library
@details When showing library info in the VIEW menu, the data is taken from
the Data Catalog tables. These may be empty or outdated, and so this service
allows end users to run a refresh of the data.
<h4> Service Inputs </h4>
<h5> lib2refresh </h5>
Should contain the libref to be refreshed.
|libref:$8.|
|---|
|SOMELIB|
<h4> Service Outputs </h4>
<h5> libinfo </h5>
|engine $|libname $|paths $|perms $|owners $|schemas $ |libid $|libsize $|table_cnt |
|---|---|---|---|---|---|---|---|---|
|V9|SOMELIB|"some/path"|rwxrwxr-x|sassrv|` `|` `|636MB|33|
<h4> SAS Macros </h4>
@li dc_assignlib.sas
@li dc_refreshcatalog.sas
@li mp_abort.sas
@version 9.3
@author 4GL Apps Ltd
@copyright 4GL Apps Ltd. This code may only be used within Data Controller
and may not be re-distributed or re-sold without the express permission of
4GL Apps Ltd.
**/
%mpeinit()
%webout(FETCH)
%mp_abort(iftrue= (&syscc ne 0)
,msg=%str(syscc=&syscc Problem on startup)
)
%let libref=;
data _null_;
set work.lib2refresh;
call symputx('libref',libref);
run;
%mp_abort(iftrue= (&syscc ne 0)
,msg=%str(syscc=&syscc Problem with inputs - was lib2refresh object sent?)
)
%dc_assignlib(WRITE,&libref)
%mp_abort(iftrue= (&syscc ne 0)
,msg=%str(syscc=&syscc after lib assignment)
)
%dc_refreshcatalog(&libref)
%mp_abort(iftrue= (&syscc ne 0)
,msg=%str(syscc=&syscc Problem when running the catalog refresh)
)
/* get libinfo */
proc sql;
create table work.libinfo as
select a.engine,
a.libname,
a.paths,
a.perms,
a.owners,
a.schemas,
a.libid,
b.libsize,
b.table_cnt
from &mpelib..mpe_datacatalog_libs(where=(&dc_dttmtfmt. lt tx_to)) a
inner join &mpelib..mpe_datastatus_libs(where=(&dc_dttmtfmt. lt tx_to)) b
on a.libref=b.libref
where a.libref="&libref";
%webout(OPEN)
%webout(OBJ,libinfo)
%webout(CLOSE)
/**
@file refreshlibinfo.sas
@brief Refresh the Data Catalog for a particular library
@details When showing library info in the VIEW menu, the data is taken from
the Data Catalog tables. These may be empty or outdated, and so this service
allows end users to run a refresh of the data.
<h4> Service Inputs </h4>
<h5> lib2refresh </h5>
Should contain the libref to be refreshed.
|libref:$8.|
|---|
|SOMELIB|
<h4> Service Outputs </h4>
<h5> libinfo </h5>
|engine $|libname $|paths $|perms $|owners $|schemas $ |libid $|libsize $|table_cnt |
|---|---|---|---|---|---|---|---|---|
|V9|SOMELIB|"some/path"|rwxrwxr-x|sassrv|` `|` `|636MB|33|
<h4> SAS Macros </h4>
@li dc_assignlib.sas
@li dc_refreshcatalog.sas
@li mp_abort.sas
@version 9.3
@author 4GL Apps Ltd
@copyright 4GL Apps Ltd. This code may only be used within Data Controller
and may not be re-distributed or re-sold without the express permission of
4GL Apps Ltd.
**/
%mpeinit()
%webout(FETCH)
%mp_abort(iftrue= (&syscc ne 0)
,msg=%str(syscc=&syscc Problem on startup)
)
%let libref=;
data _null_;
set work.lib2refresh;
call symputx('libref',libref);
run;
%mp_abort(iftrue= (&syscc ne 0)
,msg=%str(syscc=&syscc Problem with inputs - was lib2refresh object sent?)
)
%dc_assignlib(WRITE,&libref)
%mp_abort(iftrue= (&syscc ne 0)
,msg=%str(syscc=&syscc after lib assignment)
)
%dc_refreshcatalog(&libref)
%mp_abort(iftrue= (&syscc ne 0)
,msg=%str(syscc=&syscc Problem when running the catalog refresh)
)
/* get libinfo */
proc sql;
create table work.libinfo as
select a.engine,
a.libname,
a.paths,
a.perms,
a.owners,
a.schemas,
a.libid,
b.libsize,
b.table_cnt,
b.catalog_cnt
from &mpelib..mpe_datacatalog_libs(where=(&dc_dttmtfmt. lt tx_to)) a
inner join &mpelib..mpe_datastatus_libs(where=(&dc_dttmtfmt. lt tx_to)) b
on a.libref=b.libref
where a.libref="&libref";
%webout(OPEN)
%webout(OBJ,libinfo)
%webout(CLOSE)

View File

@@ -167,7 +167,8 @@ create table work.libinfo as
a.schemas,
a.libid,
coalesce(b.libsize,0) as libsize,
coalesce(b.table_cnt,0) as table_cnt
coalesce(b.table_cnt,0) as table_cnt,
coalesce(b.catalog_cnt,0) as catalog_cnt
from &mpelib..mpe_datacatalog_libs(where=(&dc_dttmtfmt. lt tx_to)) a
left join &mpelib..mpe_datastatus_libs(where=(&dc_dttmtfmt. lt tx_to)) b
on a.libref=b.libref