GROOVY('result value metadata json', ''groovy script', arg0, arg1, arg2...)
Result value metadata json
- json string representing result value metadata. Must contain non-null keys resultType
and isSingleValue
.Groovy script to execute
- groovy script string, which uses arg0
, arg1
, arg2
etc to refer to the arguments provided within the scriptarguments
- pinot columns/other transform functions that are arguments to the groovy scriptgroovy( '{"returnType":"INT","isSingleValue":true}', 'arg0 + arg1', colA, colB)
\groovy('{"returnType":"INT","isSingleValue":true}', 'arg0.toList().max()', mvColumn)
\groovy('{"returnType":"LONG","isSingleValue":false}', 'arg0.findIndexValues{ it > 5 }', mvColumn)
\groovy('{"returnType":"DOUBLE","isSingleValue":true}', 'arg0 * arg1', arraylength(mvColumn), colB)
\foo
, add values at those indexes in mvColumnBgroovy( '{"returnType":"DOUBLE","isSingleValue":true}', 'def x = 0; arg0.eachWithIndex{item, idx-> if (item == "foo") {x = x + arg1[idx] }}; return x' , mvColumnA, mvColumnB)
\groovy('{\"returnType\":\"FLOAT\", \"isSingleValue\":true}', 'def result; switch(arg0.length()) { case 10: result = 1.1; break; case 20: result = 1.2; break; default: result = 1.3;}; return result.floatValue()', mvCol)
\groovy('new Date().format( "yyyyMMdd" )', '{"returnType":"STRING","isSingleValue":true}')
pinot.broker.disable.query.groovy=true
@ScalarFunction
annotation.org.apache.pinot.scalar.XXXX
@ScalarFunction
annotation. Make sure the method is static
and returns only a single value output. The input and output can have one of the following types -/plugins
directory in pinot. You will need to restart all Pinot instances if they are already running.