Loading...
Searching...
No Matches
getdata.test.1.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing getdata row and cell limits
4
5 @details The EDIT screen is bounded by two limits - rows
6 (DC_MAXOBS_WEBEDIT) and cells, rows x columns (DC_MAXCELLS_WEBEDIT) -
7 whichever is reached first. A selection over either is SERVED TRUNCATED:
8 the grid gets the first rows that fit, and sasparams carries TRUNCATED=1
9 plus a TRUNC_MSG naming the limit, which the EDIT screen shows as a warning
10 against the table name.
11
12 Test 1 uses MPE_X_TEST (several hundred rows, few columns) so the row
13 limit alone decides the cap. Test 2 uses the fixture dctest.wideboy (1000
14 rows x 1004 columns, created and registered by testsetup) filtered to 200
15 rows: that is under the row limit but 200 x 1004 = 200,800 cells, over the
16 200,000 cell limit, so the cell limit decides the cap -
17 floor(200000 / 1004) = 199 rows. It also checks the column list is whole:
18 the cap applies to the rows the browser is sent, never to the COLS metadata.
19
20 <h4> SAS Macros </h4>
21 @li mp_assert.sas
22 @li mp_filterstore.sas
23 @li mf_getuniquefileref.sas
24 @li mx_execute.sas
25
26 @sasjslint {"maxLineLength": 86}
27
28**/
29
30%let _program=&appLoc/services/editors/getdata;
31
32/**
33 * Build a ROW_ID <= &maxrow filter on dctest.wideboy, leaving the filter_rk
34 * in &filter_rk
35 */
36%macro wideboy_filter(maxrow);
37 data work.inquery;
38 length GROUP_LOGIC $3 SUBGROUP_LOGIC $3 SUBGROUP_ID 8
39 VARIABLE_NM $32 OPERATOR_NM $10 RAW_VALUE $4000;
40 GROUP_LOGIC='AND';
41 SUBGROUP_LOGIC='AND';
42 SUBGROUP_ID=1;
43 VARIABLE_NM='ROW_ID';
44 OPERATOR_NM='LE';
45 RAW_VALUE="&maxrow";
46 output;
47 run;
48 %mp_filterstore(
49 libds=dctest.wideboy,
50 filter_summary=&dc_libref..mpe_filteranytable,
51 filter_detail=&dc_libref..mpe_filtersource,
52 lock_table=&dc_libref..mpe_lockanytable,
53 maxkeytable=&dc_libref..mpe_maxkeyvalues,
54 queryds=work.inquery,
55 outresult=work.result,
56 outquery=work.query
57 )
58 data _null_;
59 set work.result;
60 call symputx('filter_rk',filter_rk,'g');
61 run;
62%mend wideboy_filter;
63
64/**
65 * Call getdata as a child job and expose the webout as the &outlib JSON
66 * libname, so the test can read what the browser would have received.
67 */
68%macro call_getdata(libds,filter_rk,outlib);
69 %let fref=%mf_getuniquefileref();
70 data _null_;
71 file &fref termstr=crlf;
72 put 'LIBDS:$43. FILTER_RK:8.';
73 put "&libds,&filter_rk";
74 run;
75 %mx_execute(&_program,
76 viyacontext=&defaultcontext,
77 inputfiles=&fref:sascontroltable,
78 outlib=&outlib
79 )
80 %let syscc=0;
81%mend call_getdata;
82
83/**
84 * Test 1 - row limit. MPE_X_TEST is well under the cell limit, so the
85 * 250 row default is what caps the payload.
86 */
87%call_getdata(&dclib..MPE_X_TEST,-1,web1)
88
89%let t1_nobs=-1;
90%let t1_trunc=-1;
91%let t1_msg=;
92proc sql noprint;
93select count(*) into: t1_nobs from web1.sasdata;
94quit;
95data _null_;
96 set web1.sasparams;
97 call symputx('t1_trunc',truncated);
98 call symputx('t1_msg',trunc_msg);
99 putlog (_all_)(=);
100run;
101
102%mp_assert(
103 iftrue=(&t1_trunc=1),
104 desc=%str(Test 1 - a selection over the row limit is served, flagged as truncated),
105 outds=work.test_results
106)
107%mp_assert(
108 iftrue=(&t1_nobs=250),
109 desc=Test 1 - the payload is capped at DC_MAXOBS_WEBEDIT (250) rows,
110 outds=work.test_results
111)
112%mp_assert(
113 iftrue=(%index(&t1_msg,DC_MAXOBS_WEBEDIT)>0),
114 desc=Test 1 - the truncation message names the DC_MAXOBS_WEBEDIT limit,
115 outds=work.test_results
116)
117
118/**
119 * Test 2 - cell limit (200 rows x 1004 cols = 200,800 > 200,000)
120 */
121%wideboy_filter(200)
122%call_getdata(dctest.wideboy,&filter_rk,web2)
123
124%let t2_nobs=-1;
125%let t2_trunc=-1;
126%let t2_msg=;
127proc sql noprint;
128select count(*) into: t2_nobs from web2.sasdata;
129quit;
130data _null_;
131 set web2.sasparams;
132 call symputx('t2_trunc',truncated);
133 call symputx('t2_msg',trunc_msg);
134 putlog (_all_)(=);
135run;
136
137%mp_assert(
138 iftrue=(&t2_trunc=1),
139 desc=%str(Test 2 - a selection over the cell limit is served, flagged as truncated),
140 outds=work.test_results
141)
142%mp_assert(
143 iftrue=(&t2_nobs=199),
144 desc=Test 2 - the payload is capped at floor(DC_MAXCELLS_WEBEDIT / cols),
145 outds=work.test_results
146)
147%mp_assert(
148 iftrue=(%index(&t2_msg,DC_MAXCELLS_WEBEDIT)>0),
149 desc=Test 2 - the truncation message names the DC_MAXCELLS_WEBEDIT limit,
150 outds=work.test_results
151)
152
153/**
154 * The row cap must not reach the metadata: the COLS payload for this table
155 * describes every column, not the 199 rows the cell limit admits. A row cap
156 * left set as a session option would cut the column list to 199 entries, and
157 * a grid losing 800 columns looks like a missing table rather than a limit.
158 */
159%let t2_cols=-1;
160%let t2_phys=-1;
161proc sql noprint;
162select count(*) into: t2_cols from web2.cols;
163select count(*) into: t2_phys
164 from dictionary.columns
165 where libname='DCTEST' and memname='WIDEBOY';
166quit;
167
168%mp_assert(
169 iftrue=(&t2_cols=&t2_phys),
170 desc=%str(Test 2 - every column is described, not just the rows the cap admits),
171 outds=work.test_results
172)
173
174/**
175 * dump results to the log for offline inspection
176 */
177data _null_;
178 set work.test_results;
179 putlog 'TEST_RESULT_LINE: ' test_result ' - ' test_description;
180run;