cancel
Showing results for 
Search instead for 
Did you mean: 
Community Platform Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results for 
Search instead for 
Did you mean: 

Issues around float datatypes

inagar
New Contributor

Float data from file, is never getting copied to the temp_table created though the schema matches.
As a workaround, using CREATE TABLE [USING] which is able to insert the file data to a temp_table. Is this a known issue?

 
COPY INTO issue is explained with screenshots below:
Structure of the table:

Screenshot 2024-06-21 at 10.45.02 PM.pngScreenshot 2024-06-21 at 10.50.59 PM.pngScreenshot 2024-06-21 at 10.53.57 PM.pngScreenshot 2024-06-21 at 10.57.24 PM.pngScreenshot 2024-06-21 at 10.58.33 PM.png

 

Another issue that we are observing in loading data to the Float column of a table, we see random digits are being appended. Is there any logic behind appending/truncating float values ? 

Screenshot 2024-06-21 at 11.12.13 PM.png

2 REPLIES 2

Witold
Contributor III

You're inferring the schema ("spark is guessing it") from the CSV. In your case either double or decimal is used. Instead, provide the schema while reading the files.

These "rounding errors" usually occur during floating-point calculations. Please make sure to use the same data type anywhere. Databricks supports at least three: FLOAT, DOUBLE and all variations of DECIMAL.

Rishabh_Tiwari
Databricks Employee
Databricks Employee

Hi @inagar ,

Thank you for reaching out to our community! We're here to help you. 

To ensure we provide you with the best support, could you please take a moment to review the response and choose the one that best answers your question? Your feedback not only helps us assist you better but also benefits other community members who may have similar questions in the future.

If you found the answer helpful, consider giving it a kudo. If the response fully addresses your question, please mark it as the accepted solution. This will help us close the thread and ensure your question is resolved.

We appreciate your participation and are here to assist you further if you need it!

Thanks,

Rishabh

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