Эх сурвалжийг харах

HUE-2508 [pig] Do not show %declare parameters in the submission popup

%declare in Pig are like constants, so we should not prompt for a value
when submitting the script.

e.g.
%declare cm 'ls';
$cmd;

Won't ask for a value for cmd.
Romain Rigaux 10 жил өмнө
parent
commit
25574f0

+ 9 - 0
apps/pig/src/pig/static/pig/js/pig.ko.js

@@ -69,6 +69,7 @@ var PigScript = function (pigScript) {
   self.getParameters = function () {
     var params = {};
     var variables = this.script().match(/([^\\]|^)\$[^\d'"](\w*)/g);
+    var declares = this.script().match(/%declare +([^ ])+/gi);
     var macro_defines = this.script().match(/define [^ ]+ *\(([^\)]*)\)/gi); // no multiline
     var macro_returns = this.script().match(/returns +([^\{]*)/gi); // no multiline
 
@@ -78,6 +79,14 @@ var PigScript = function (pigScript) {
         params[p] = '';
       });
     }
+    if (declares) {
+      $.each(declares, function(index, param) {
+    	param = param.match(/(\w+)/g);
+    	if (param && param.length >= 2) {
+    	  delete params[param[1]];
+    	}
+      });
+    }
     if (macro_defines) {
       $.each(macro_defines, function(index, params_line) {
         var param_line = params_line.match(/(\w+)/g);