@sasjs/core 7.1.1 → 7.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,8 @@
26
26
  %mp_filtervalidate(myfilter,sashelp.class)
27
27
 
28
28
  @returns The SYSCC value will be 1008 if there are validation issues.
29
+ On an abort the message carries the reason and the clause that failed, so
30
+ the inputs are visible without reading the log.
29
31
 
30
32
  @param [in] inref The input fileref to validate (generated by
31
33
  mp_filtergenerate.sas)
@@ -56,12 +58,14 @@
56
58
  ,msg=%str(syscc=&syscc / syserr=&syserr - on macro entry)
57
59
  )
58
60
 
59
- %local fref1;
61
+ %local fref1 flt_clause flt_msg;
60
62
  %let fref1=%mf_getuniquefileref();
61
63
 
62
64
  data _null_;
63
65
  file &fref1;
64
66
  infile &inref end=eof;
67
+ length flt_clause $4000;
68
+ retain flt_clause;
65
69
  if _n_=1 then do;
66
70
  put "proc sql;";
67
71
  put "validate select * from &targetds";
@@ -70,7 +74,13 @@ data _null_;
70
74
  input;
71
75
  put _infile_;
72
76
  putlog _infile_;
73
- if eof then put ";quit;";
77
+ /* the generated clause, kept so a failure can name the inputs it was given -
78
+ the SQL message reports only the clashing data types */
79
+ flt_clause=cats(flt_clause,ifc(_n_>1,' ',''),strip(_infile_));
80
+ if eof then do;
81
+ put ";quit;";
82
+ call symputx('flt_clause',flt_clause,'l');
83
+ end;
74
84
  run;
75
85
 
76
86
  %inc &fref1;
@@ -90,12 +100,18 @@ filename &fref1 clear;
90
100
  %if &abort=YES %then %do;
91
101
  data _null_;
92
102
  set &outds;
103
+ length flt_msg $4000;
93
104
  call symputx('REASON_CD',reason_cd,'l');
105
+ /* the clause is reported with the reason: the SQL message says which
106
+ types clashed but not which inputs produced it */
107
+ flt_msg=catx(' ','Filter validation issues:',reason_cd
108
+ ,catx(' ','Clause: where',symget('flt_clause')));
109
+ call symputx('flt_msg',flt_msg,'l');
94
110
  stop;
95
111
  run;
96
112
  %mp_abort(
97
113
  mac=&sysmacroname,
98
- msg=%str(Filter validation issues.)
114
+ msg=%superq(flt_msg)
99
115
  )
100
116
  %end;
101
117
  %let syscc=1008;
package/package.json CHANGED
@@ -43,5 +43,5 @@
43
43
  "devDependencies": {
44
44
  "@nogoo9/gitleaks": "8.30.1-post.2"
45
45
  },
46
- "version": "7.1.1"
46
+ "version": "7.1.3"
47
47
  }
@@ -72,6 +72,11 @@
72
72
  engine. Example values:
73
73
  @li WEBOUT_JSON
74
74
  @li WEBOUT_TXT
75
+ A job whose webout is a binary file registers it under its own name -
76
+ `_webout.pdf`, `_webout.xlsx` and so on - and a dotted key cannot be
77
+ requested through this parameter. When the requested member is absent the
78
+ macro falls back to the first `_WEBOUT*` member of the results that holds a
79
+ files uri, so a binary webout is returned without the caller naming it.
75
80
 
76
81
  @param [out] outref= (0) The output fileref to which to write the results
77
82
  @param [out] outlib= (0) The output library to which to assign the results
@@ -99,12 +104,10 @@
99
104
  ,outref=0
100
105
  ,outlib=0
101
106
  );
102
- %local dbg;
103
107
  %if &mdebug=1 %then %do;
104
108
  %put &sysmacroname entry vars:;
105
109
  %put _local_;
106
110
  %end;
107
- %else %let dbg=*;
108
111
 
109
112
  %local oauth_bearer;
110
113
  %if &grant_type=detect %then %do;
@@ -180,15 +183,49 @@ run;
180
183
  %end;
181
184
 
182
185
  /* extract results link */
183
- %local lib1 resuri;
186
+ %local lib1 resuri resname resfall want;
187
+ %let resfall=0;
188
+ %let want=%upcase(_&result);
184
189
  %let lib1=%mf_getuniquelibref();
185
190
  libname &lib1 JSON fileref=&fname1;
191
+ /* The member is located by name rather than referenced by name: a results
192
+ * table with no such column cannot be addressed in a data step at all. A
193
+ * binary webout registers itself as _webout.pdf / .xlsx / .zip, which
194
+ * result= cannot express, so when the requested member is missing the first
195
+ * _WEBOUT* column holding a files uri is taken instead - a job that
196
+ * registered more than one binary member cannot steer this, so only one
197
+ * binary member per job is supported. */
186
198
  data _null_;
187
199
  set &lib1..results;
188
- call symputx('resuri',_&result,'l');
189
- &dbg putlog "&sysmacroname results: " (_all_)(=);
200
+ array _chars{*} _character_;
201
+ length _name $32 _val $512;
202
+ do _i=1 to dim(_chars);
203
+ _name=vname(_chars{_i});
204
+ if upcase(_name)=symget('want') then do;
205
+ _val=_chars{_i};
206
+ leave;
207
+ end;
208
+ end;
209
+ if _val eq '' then do _i=1 to dim(_chars);
210
+ _name=vname(_chars{_i});
211
+ if _chars{_i}=:'/files/' and upcase(_name)=:'_WEBOUT' then do;
212
+ _val=_chars{_i};
213
+ call symputx('resfall',1,'l');
214
+ leave;
215
+ end;
216
+ end;
217
+ if _val ne '' then do;
218
+ call symputx('resuri',_val,'l');
219
+ call symputx('resname',_name,'l');
220
+ end;
221
+ %if &mdebug=1 %then %do;
222
+ putlog "&sysmacroname results: " (_all_)(=);
223
+ %end;
190
224
  run;
191
- %if "&resuri"="." %then %do;
225
+ %if &mdebug=1 and &resfall=1 %then %do;
226
+ %put &sysmacroname: _&result was not registered, using &resname;
227
+ %end;
228
+ %if "%superq(resuri)" eq "" or "%superq(resuri)" eq "." %then %do;
192
229
  /* The requested result was not registered - typical for a canceled
193
230
  * job whose session ended before the result file was created (eg a
194
231
  * job aborted by design, or a job that failed on session creation).
@@ -218,10 +255,6 @@ run;
218
255
  %end;
219
256
  %return;
220
257
  %end;
221
- %mp_abort(iftrue=("&resuri"=".")
222
- ,mac=&sysmacroname
223
- ,msg=%str(Variable _&result did not exist in the response json)
224
- )
225
258
 
226
259
  /* extract results */
227
260
  %local fname2;