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
Community Manager
Community Manager

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