Jdbc input plugin and a null value to a output jdbc plugin

I'm using a jdbc input(sqlserver) to input data in a postgresql with jdbc output.

input {
    jdbc {
        jdbc_connection_string => "***"
        jdbc_driver_library => "***"
        jdbc_user => "***"
        jdbc_password => "***"
        jdbc_driver_class => "***"
        statement_filepath => "***"
        last_run_metadata_path => "***"
        use_column_value => true
        tracking_column => id
        schedule => "*/1 * * * *"
    }
}
output {
    jdbc {
        connection_string => '***'
        statement => [ "insert into my_table(number_field) values (?)", "number_input_field" ]
    }
}

and i'm receiving this error.

[2019-07-30T15:04:03,890][ERROR][logstash.outputs.jdbc ] JDBC - Exception. Not retrying {:exception=>org.postgresql.util.PSQLException: ERROR: column "number_field" is of type integer but expression is of type character varying
Dica: You will need to rewrite or cast the expression.
Posição: 563, :statement=>"insert into my_table(number_field) values (?)", :event=>"{"number_input_field":null}"}

The table on sql server(input) has a integer field(number_input_fiel) that can assume null value, when it cames a null value, he's considering that is a varchar value('null') and not a null value(null).

Maybe that could help?

ruby {
  code => "
    event.set('number_input_field', nil) if !(event.get('number_input_field').is_a? Integer)
  "
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.