Hello,

I'm using this as a reference to test some expression language on the
command line:

https://gist.github.com/mattyb149/13b9bceeace1f7db76f648dfb200b680

This works fine;
λ ~/software/nifi-tools groovy testEL-1.9.2.groovy -D dt "2020-02-21
12:00:00" '${dt:toDate("yyyy-MM-dd HH:mm:ss"):minus(43200000):toDate()}'
Fri Feb 21 00:00:00 MST 2020

But with 1.11.1, we're getting the following error

λ ~/software/nifi-tools groovy testEL-1.11.1.groovy -D dt "2020-02-21
12:00:00" '${dt:toDate("yyyy-MM-dd HH:mm:ss"):minus(43200000):toDate()}'
Caught: groovy.lang.MissingMethodException: No signature of method:
org.apache.nifi.attribute.expression.language.Query.evaluate() is
applicable for argument types: (LinkedHashMap) values: [[dt:2020-02-21
12:00:00]]
groovy.lang.MissingMethodException: No signature of method:
org.apache.nifi.attribute.expression.language.Query.evaluate() is
applicable for argument types: (LinkedHashMap) values: [[dt:2020-02-21
12:00:00]]
at testEL-1_11_1$_run_closure2.doCall(testEL-1.11.1.groovy:27)
at testEL-1_11_1.run(testEL-1.11.1.groovy:25)
λ ~/software/nifi-tools

Here's me script:

@Grab(group='org.apache.nifi', module='nifi-expression-language',
version='1.11.1')
import org.apache.nifi.attribute.expression.language.*

def cli = new CliBuilder(usage:'groovy testEL.groovy [options]
[expressions]',
                          header:'Options:')
cli.help('print this message')
cli.D(args:2, valueSeparator:'=', argName:'attribute=value',
       'set value for given attribute')
def options = cli.parse(args)
if(!options.arguments()) {
  cli.usage()
  return 1
}

def attrMap = [:]
def currKey = null
options.Ds?.eachWithIndex {o,i ->
  if(i%2==0) {
    currKey = o
  } else {
    attrMap[currKey] = o
  }
}
options.arguments()?.each {
  def q = Query.compile(it)
  println q.evaluate(attrMap ?: null)
}

Any insight into why this isn't working in 1.11.x now?

Regards,

Dano

Reply via email to