questdb.io icon indicating copy to clipboard operation
questdb.io copied to clipboard

Update rules for implicit conversion

Open jerrinot opened this issue 3 years ago • 2 comments

I'm confused by this page https://questdb.io/docs/reference/sql/cast/#implicit-conversion It says:

QuestDB will only perform implicit cast when they would not result in data being truncated or precision being lost.

But then there is this diagram: image

The diagram says that some conversion may cause precision loss. Which is inconsistent with the claim quoted above.

Moreover, I don't know how to interpret the diagram. I assume one axis is "from-type" and another axis is "to-type". But I don't know which axis is which.

And last but not least: We should check whether the rules are still valid after https://github.com/questdb/questdb/pull/2423/ is merged.

jerrinot avatar Sep 27 '22 08:09 jerrinot

Related: Our implicit cast can cause precision loss. For example when casting a big long number to double will loss some of the less significant digits. For example a long value 9223372036854775806 will be converted to double as 9223372036854776000

jerrinot avatar Sep 27 '22 09:09 jerrinot

I looked into this with Vlad a while ago. He pointed me to this: https://www.mssqltips.com/sqlservertip/6874/sql-cast-function-for-data-type-conversions/

TODO: Diagram:

  1. Original image probably cannot be retrieved so create new one?
  2. Understand how to confirm whether there is precision loss or not Text:
  3. Understand when QuestDB will perform implicit conversion

amyshwang avatar Oct 06 '22 18:10 amyshwang