cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Autolodaer schemaHints convert valid values to null

_databreaks
New Contributor II

I am ingesting json files from S3 using Autoloader and would like to use schemaHints to define the datatype of one of the fields, that is, I wanted the field id to be of integer type.

The DLT code below infers the the id as string, with correct values.

 

create streaming table raw as
select * 
from cloud_files('/path', 'json',
  map("cloudFiles.inferColumnTypes", "true")
  );

 

But I would like the id column to be integer type, hence wanted to use schemaHints like below :

 

create streaming table raw as
select * 
from cloud_files('/path', 'json',
  map("cloudFiles.inferColumnTypes", "true",
      "cloudFiles.schemaHints", "id LONG"
  )
)

 

The resulting table will have the correct data type but all the values of the column/field id are now null.

I've done some checking on the data such as isnotnull(int(id)) to see if there is any record in not convertible to int but surprise surprise, all ids are castable to int.

I already have a work-around in mind. I just want to understand why would autoloader do that?

Is this a known issue/bug?

Regards.

 

0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group