- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2022 08:46 AM
My job started failing with the below error when inserting rows into a delta table.
ailing with the below error when inserting rows (timestamp) to a delta table, it was working well before.
java.lang.ArithmeticException: Casting XXXXXXXXXXX to int causes overflow
- Labels:
-
Int
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2022 08:49 AM
This is because the Integer type represents 4-byte signed integer numbers. The range of numbers is from -2147483648 to 2147483647.
Kindly use double as the data type to insert the "2147483648" value in the delta table.
In the below example, The second insert will fail when we insert it into the table because it is exceeding the maximum allowed range for int data type. However as a double data type. The value would be successfully inserted because double represents 8-byte signed integer numbers.
Eg. CREATE TABLE test (c1 int, c2 double);
INSERT INTO test VALUES (2147483647, 2147483647);
INSERT INTO test VALUES (100574987462592, 100574987462592);
INSERT INTO test VALUES (NULL, 100574987462592);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2022 08:49 AM
This is because the Integer type represents 4-byte signed integer numbers. The range of numbers is from -2147483648 to 2147483647.
Kindly use double as the data type to insert the "2147483648" value in the delta table.
In the below example, The second insert will fail when we insert it into the table because it is exceeding the maximum allowed range for int data type. However as a double data type. The value would be successfully inserted because double represents 8-byte signed integer numbers.
Eg. CREATE TABLE test (c1 int, c2 double);
INSERT INTO test VALUES (2147483647, 2147483647);
INSERT INTO test VALUES (100574987462592, 100574987462592);
INSERT INTO test VALUES (NULL, 100574987462592);

