zendesk / maxwell

Maxwell's daemon, a mysql-to-json kafka producer
https://maxwells-daemon.io/
Other
4.04k stars 1.01k forks source link

Can't change database in javascript filter #1384

Open farshidz opened 4 years ago

farshidz commented 4 years ago

I'm trying to write a filer that adds a prefix to database. I tried this, which doesn't do anything:

function process_row(row) {
    row.database = "mt4_" + row.database;
    return row;
}

Also this failed because row is not a map:

function process_row(row) {
    row.put("database", "mt4_" + row.database);
}

Is there a way to this this or is data the only part of the record that can be modified in a filter?

osheroff commented 4 years ago

currently only data and some select properties can be modified. Would I accept a PR to change it? Maybe. Seems like there's some pretty huge potential for shooting oneself in the foot there (and as an open source maintainer, let me tell you, people love shooting at their feet).

Wondering if the extra_attributes hash (general dumping ground for javascript filters) might work for you?