cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Error when Inserting data into table with the column as bigint

Jits
New Contributor II

Hi All,

I am creating table using Databricks SQL editor. The table definition is

DROP TABLE IF EXISTS [database].***_test;

CREATE TABLE [database].***_jitu_test

(

  id bigint

)

USING delta

LOCATION 'test/raw/***_jitu_test'

TBLPROPERTIES ('delta.minReaderVersion'='1','delta.minWriterVersion'='2','delta.feature.allowColumnDefaults' = 'supported');

Table gets create successfully. When I do insert

insert into [database].***_test (id ) values (1);

It give error.

Java.lang.Integer cannot be cast to java.lang.Long

I don't want to so cast because then in every column with bigint I have to write cast. I tried using below with now luck. is there configuration I have to set or its the issue with product

--SET ansi_mode = true;

--SET spark.sql.ansi.enabled=true;

2 REPLIES 2

-werners-
Esteemed Contributor III

can you try with values(1L)?

The L part specifies the number is a longType.

https://spark.apache.org/docs/latest/sql-ref-literals.html#numeric-literal

Anonymous
Not applicable

Hi @jitendra goswami​ 

We haven't heard from you since the last response from @Werner Stinckens​ r​, and I was checking back to see if her suggestions helped you.

Or else, If you have any solution, please share it with the community, as it can be helpful to others. 

Also, Please don't forget to click on the "Select As Best" button whenever the information provided helps resolve your question.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.