Discussion:
"invalid input syntax for integer" for number with exponent
Stephen Froehlich
2018-02-28 21:16:37 UTC
Permalink
I'm getting the following error when trying to go from R to a bigint field in PostgreSQL.

COPY invalid input syntax for integer: "1.12589990684262e+015"

Do I need to convert the number into text manually in R? Exactly what about this input is confusing PostgreSQL?

Thanks,
Stephen

________________________________
Stephen Froehlich
Sr. Strategist, CableLabs(r)

***@cablelabs.com<mailto:***@cablelabs.com>
Tel: +1 (303) 661-3708
Bzzzz
2018-02-28 21:24:20 UTC
Permalink
On Wed, 28 Feb 2018 21:16:37 +0000
Post by Stephen Froehlich
I'm getting the following error when trying to go from R to a bigint field in PostgreSQL.
COPY invalid input syntax for integer: "1.12589990684262e+015"
Do I need to convert the number into text manually in R? Exactly what
about this input is confusing PostgreSQL?
Take a closer look at this number: is it a FLOAT, not an integer, thus
you get an error trying to insert a float in an integer column.

JY
David G. Johnston
2018-02-28 21:59:15 UTC
Permalink
Post by Bzzzz
On Wed, 28 Feb 2018 21:16:37 +0000
Post by Stephen Froehlich
I'm getting the following error when trying to go from R to a bigint
field in PostgreSQL.
COPY invalid input syntax for integer: "1.12589990684262e+015"
Do I need to convert the number into text manually in R? Exactly what
about this input is confusing PostgreSQL?
SELECT '1e4'::integer; -- fails with the same message in PostgreSQL; the
text input function for integers doesn't understand scientific notation.

You will need to ensure that R outputs its numbers in non-scientific format
in order to copy them into PostgreSQL via an intermediate text file.

Take a closer look at this number: is it a FLOAT, not an integer, thus
Post by Bzzzz
you get an error trying to insert a float in an integer column.
​Uh, no, that is not what the error is saying...though it is quite possible
if this error wasn't present what you say might happen. The OP does have
confusion somewhere in the schema since the copy command is trying to use
integer while the stated desire is bigint.

David J.

Loading...