trinodb / trino

Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
https://trino.io
Apache License 2.0
10.28k stars 2.96k forks source link

Current testing technique does not catch some cases when the return value is not valid for given type #5738

Open findepi opened 3 years ago

findepi commented 3 years ago

io.prestosql.sql.query.QueryAssertions#expression(java.lang.String) + matches can pass eveb when value is not correct for given type: eg not properly truncated (char with trailing spaces), or not properly rounded (timestamp with not max precision).

See https://github.com/prestosql/presto/issues/5736#issuecomment-718846167 for example.

Implementation plan:

Add checks within (explicitly or implicitly) io.prestosql.spi.type.Type#getObjectValue implementations:

findepi commented 3 years ago

I updated the description with the checklist. @prestosql/maintainers please update if any more checks we should add come to your mind.

findepi commented 2 years ago

We still need to add checks for decimal. So far @ksobolew added a check flagging "negative zero", but we also need precision/scale checks.

cc @ksobolew @lukasz-stec