logstash-plugins / logstash-filter-math

This plugin provides the ability to do various simple math operations (addition, subtraction, multiplication and division) on document fields
Apache License 2.0
1 stars 8 forks source link

Should preserve the Timestamp type when a Timestamp is on the LHS of an operation. #11

Open guyboertje opened 6 years ago

guyboertje commented 6 years ago

Currently, the Timestamp get converted to a float via Time and the result is stored as a float.

We should preserve the "type" by making it a Timestamp from the float.

guyboertje commented 6 years ago

This not inherently do-able within the code due to the separation of the Field setter from the Operators. Each operator is abstracted and expects to be given a numeric Float or Integer.

I coded up a unary Operator - ToTimestamp, but because the config is setup for binary operations only one has to pass in an unused Literal as the second operand and I don't like the result. ["to_timestamp", "MEM[0]", 0, "[my_timestamp]"]