Skip to content
This repository was archived by the owner on Sep 17, 2019. It is now read-only.
This repository was archived by the owner on Sep 17, 2019. It is now read-only.

Postgresql numeric values lost precision #128

Open
@yuezhuangshi

Description

@yuezhuangshi

Hi,

I'm working with postgresql and insert 18.54322356 to a numeric field with 8 scale, but actually I got 18.54320000.
I also run sql in the database directly and the results is as same as my input.
INSERT INTO http_poller(id, name, birthdate, isrich, money) VALUES(5555, '2', '2018-01-05T02:02:02.000', true, 18.04623585)

output received:(money is the field lost precision)
[2018-08-15T13:49:18,128][DEBUG][logstash.pipeline ] output received {"event"=>{"id"=>1431, "name"=>"leader1431", "@timestamp"=>2018-08-15T05:49:18.019Z, "type"=>"mongo", "tags"=>["leader"], "rich"=>true, "http_poller_metadata"=>{"name"=>"leaderservice", "runtime_seconds"=>0.0032660000000000002, "response_message"=>"OK", "host"=>"jasper.local", "times_retried"=>0, "code"=>200, "response_headers"=>{"connection"=>"keep-alive", "transfer-encoding"=>"chunked", "content-type"=>"application/json;charset=UTF-8", "date"=>"Wed, 15 Aug 2018 05:49:18 GMT"}, "request"=>{"url"=>"http://localhost:8080/leader", "method"=>"get"}}, "@version"=>"1", "birthdate"=>"2018-08-15T13:49:18.018", "money"=>18.65423154}}
statement:
statement => ["insert into http_poller(id, name, birthdate, isrich, money) values(?,?,CAST(? AS timestamp),?,?)","[id]", "[name]", "[birthdate]", "[rich]", "[money]"]
table structure:
`


-- Table structure for http_poller


DROP TABLE IF EXISTS "public"."http_poller";
CREATE TABLE "public"."http_poller" (
"id" int4 NOT NULL,
"name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"birthdate" timestamp(6) NOT NULL,
"isrich" bool NOT NULL,
"money" numeric(255,8) NOT NULL
)
;
ALTER TABLE "public"."http_poller" OWNER TO "centos";
COMMENT ON COLUMN "public"."http_poller"."birthdate" IS ' ';


-- Primary Key structure for table http_poller


ALTER TABLE "public"."http_poller" ADD CONSTRAINT "http_poller_pkey" PRIMARY KEY ("id");
`

environment:
logstash-6.3.2
logstash-output-jdbc plugin installed by using logstash-plugin install logstash-output-jdbc
postgresql 9.6.2

I don't know how it happened, can you help me?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions