Expected Behavior
I use a lot of Groovy scripts to transform datasets.
To give a little context: in Groovy, when we use string substitution, like "${key} ${value}"
, it creates an instance of GString
(it's not String
). Unfortunately, these instances are not properly serialized when written in ION files.
For example, if I have this script:
def value = "awesome"
row = "Kestra is ${value}!"
When serialized in ION, I would like to have this result:
Actual Behaviour
But, I find:
{values:["awesome"],strings:["Kestra is ","!"],empty:false,valueCount:1,bytes:{{S2VzdHJhIGlzIGF3ZXNvbWUh}}}
The GString
object is serialized as a POJO, instead of calling its representation with toString()
For other needs, I created this Jackson module, registrable mapper.registerModule(new GroovyModule())
:
public class GroovyModule extends SimpleModule {
public GroovyModule() {
addSerializer(GString.class, new GStringSerializer());
}
private static class GStringSerializer extends ToStringSerializerBase {
public GStringSerializer() {
super(GString.class);
}
@Override
public String valueToString(Object value) {
return value.toString();
}
}
}
Steps To Reproduce
No response
Environment Information
- Kestra Version: 0.13.4
- Operating System (OS / Docker / Kubernetes): K8S
Example flow
id: bad-serdes
namespace: dev.yvrng
tasks:
- id: transform
type: io.kestra.plugin.scripts.groovy.FileTransform
from: >
[{"value":"awesome"}]
script: >
row = "Kestra is ${row.value}!"