Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Apr 23, 2023

📚 Context

The number column of st.dataframe and st.data_editor is not able to handle numbers larger than 2^53 as explained in this issue: #6311

Unfortunately, we cannot easily fix this since we rely on Number in Javascript (which has this limit) in the number column implementation. Therefore, in this case, we are showing a warning to make it more obvious that the shown value cannot handle as a number value. However, we expect that this is only an issue in very very few situations since it is unlikely that users are using such big numbers. Another workaround for users is to convert the column to string, which will be able to show all numbers, regardless of size correctly.

  • What kind of change does this PR introduce?

    • Bugfix
    • Feature
    • Refactoring
    • Other, please describe:

🧪 Testing Done

  • Screenshots included
  • Added/Updated unit tests
  • Added/Updated e2e tests

🧠 Description of Changes

Revised:

image

Current:

image

The int64 value of 1009513310189256287 is shown as 1009513310189256300. This is caused by JavaScript not supporting these large integers with Number (see here, max is 9007199254740991).

🧪 Testing Done

  • Screenshots included
  • Added/Updated unit tests
  • Added/Updated e2e tests

🌐 References

Does this depend on other work, documents, or tickets?


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@lukasmasuch lukasmasuch added the security-assessment-completed Security assessment has been completed for PR label Apr 23, 2023
@lukasmasuch lukasmasuch changed the title Show error for unsafe integer cells in st.dataframe Show warning for unsafe integer cells in st.dataframe Apr 23, 2023
"⚠️ 1234567898765432123\n\nThe value is larger than the maximum supported integer values in number columns (2^53).\n"
)

const safeCell = mockColumn.getCell("1234567898765432")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this test be a separate test?
I would expect this to be a separate test or the description to be longer. I prefer a separate test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point 👍 I will extract this as separate test

@lukasmasuch lukasmasuch merged commit 20b5ba0 into develop Apr 25, 2023
tconkling added a commit to tconkling/streamlit that referenced this pull request Apr 25, 2023
* develop:
  Decouple MetricsManager from AppNode (streamlit#6557)
  Fix top padding on sidebar when embed is true (streamlit#6565)
  Add support for cell and column header tooltips in the dataframe component (streamlit#6561)
  Update dataframe column properties on frontend (streamlit#6554)
  Show warning for unsafe integer cells in `st.dataframe` (streamlit#6549)
  Add icon for editable columns in `st.data_editor` (streamlit#6550)
  Unify missing values to None in the returned datastructure by `st.data_editor`.  (streamlit#6544)
  Clean up and reorganize element tree module (streamlit#6522)
  ESLint: use `--cache` flag (30x speedup!) (streamlit#6555)
  Replace `st.connection` with `st.experimental_connection` in docstring examples (streamlit#6553)
  Improve editing on touch devices for `st.data_editor` (streamlit#6548)
  Move pandas styler logic to dedicated module (streamlit#6543)
@sfc-gh-kmcgrady sfc-gh-kmcgrady deleted the fix/show-error-for-unsafe-ints branch October 5, 2023 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Large integers are not rendered correctly

3 participants