I have a need to insert data into a Databricks table using data from a csv file.
I’ve uploaded the file to Databricks, but when I try to use it to insert data into the table using copy into
, I get an error that the command is not interpreting the column in the csv file as an integer, but as a string and it is not casting that string to an int. The file was uploaded using the REST API.
How do I get Databricks to write these data to the table?
This is the code I’m currently using.
COPY INTO concept
FROM '/FileStore/tables/prod//ohdsi/demo_cdm/concept/concept.csv'
FILEFORMAT = CSV
FORMAT_OPTIONS ('mergeSchema' = 'true',
'inferSchema' ='true',
'delimiter' = ',',
'header' = 'true')
COPY_OPTIONS ('mergeSchema' = 'true');
This also fails
COPY INTO concept
FROM '/FileStore/tables/prod//ohdsi/demo_cdm/concept/concept.csv'
FILEFORMAT = CSV
FORMAT_OPTIONS (
'delimiter' = ',',
'header' = 'true')
;
This is the error message
Error in SQL statement: AnalysisException: Failed to merge fields 'concept_id' and 'concept_id'. Failed to merge incompatible data types IntegerType and StringType