Add detection of out-of-bound NUMERICs - #562
Conversation
e70bf63 to
4313a09
Compare
|
Hi! I wonder if you would like to take a look at this PR, whether it does not break the use-cases you covered in #560? |
|
It shouldn't break my use-case. Some uses of unbound in the naming could be updated to avoid confusion as it's possible for an unbound numeric to hold ordinary numbers, this is more detecting non-finite/special cases of numerics. I think setting |
4313a09 to
6e30a89
Compare
This is a backport of the PR duckdb#562 to `v1.5-variegata` stable branch. This PR adds detection of `NaN`, `Infinity` and `-Infinity` values of Postgres' `NUMERIC` colums with the following logic: - for bound `NUMERIC(p,s)` columns: - if options `pg_numeric_nan_as_null` is enabled (default: `TRUE`) - `NULL` is returned on `NaN` value - otherwise, an error is thrown - Postgres bound `NUMERIC(p,s)` columns cannot hold `Infinity` or `-Infinity` values - for unbound `NUMERIC` columns: - if option `pg_numeric_as_varchar` is enabled (default: `FALSE`) - then a `VARCHAR` representation is returned as `NaN`, `Infinity` or `-Infinity` string - otherwise `DOUBLE` value is returned holding DuckDB-native `NaN`, `Infinity` or `-Infinity` double number Testing: new test is added with an out-of-bound coverage of both options and of all `NUMERIC` storage types. Ref: duckdb/duckdb#23971
This PR adds detection of `NaN`, `Infinity` and `-Infinity` values of
Postgres' `NUMERIC` colums with the following logic:
- for bound `NUMERIC(p,s)` columns:
- if options `pg_numeric_nan_as_null` is enabled (default: `TRUE`) -
`NULL` is returned on `NaN` value
- otherwise, an error is thrown
- Postgres bound `NUMERIC(p,s)` columns cannot hold `Infinity` or
`-Infinity` values
- for unbound `NUMERIC` columns:
- if option `pg_numeric_as_varchar` is enabled (default: `FALSE`) -
then a `VARCHAR` representation is returned as `NaN`, `Infinity` or
`-Infinity` string
- otherwise `DOUBLE` value is returned holding DuckDB-native `NaN`,
`Infinity` or `-Infinity` double number
Testing: new test is added with an out-of-bound coverage of both options
and of all `NUMERIC` storage types.
Ref: duckdb/duckdb#23971
6e30a89 to
46e8cde
Compare
This is a backport of the PR duckdb#562 to `v1.5-variegata` stable branch. This PR adds detection of `NaN`, `Infinity` and `-Infinity` values of Postgres' `NUMERIC` colums with the following logic: - for bound `NUMERIC(p,s)` columns: - if options `pg_numeric_nan_as_null` is enabled (default: `TRUE`) - `NULL` is returned on `NaN` value - otherwise, an error is thrown - Postgres bound `NUMERIC(p,s)` columns cannot hold `Infinity` or `-Infinity` values - for unbound `NUMERIC` columns: - if option `pg_numeric_as_varchar` is enabled (default: `FALSE`) - then a `VARCHAR` representation is returned as `NaN`, `Infinity` or `-Infinity` string - otherwise `DOUBLE` value is returned holding DuckDB-native `NaN`, `Infinity` or `-Infinity` double number Testing: new test is added with an out-of-bound coverage of both options and of all `NUMERIC` storage types. Ref: duckdb/duckdb#23971
Changed "unbound" (that was intended to be named "out-of-bound", but became ambiguous) to "non-finite".
This is a good catch, added type config init there and the test coverage. |
This is a backport of the PR #562 to `v1.5-variegata` stable branch. This PR adds detection of `NaN`, `Infinity` and `-Infinity` values of Postgres' `NUMERIC` colums with the following logic: - for bound `NUMERIC(p,s)` columns: - if options `pg_numeric_nan_as_null` is enabled (default: `TRUE`) - `NULL` is returned on `NaN` value - otherwise, an error is thrown - Postgres bound `NUMERIC(p,s)` columns cannot hold `Infinity` or `-Infinity` values - for unbound `NUMERIC` columns: - if option `pg_numeric_as_varchar` is enabled (default: `FALSE`) - then a `VARCHAR` representation is returned as `NaN`, `Infinity` or `-Infinity` string - otherwise `DOUBLE` value is returned holding DuckDB-native `NaN`, `Infinity` or `-Infinity` double number Testing: new test is added with an out-of-bound coverage of both options and of all `NUMERIC` storage types. Ref: duckdb/duckdb#23971
This PR adds detection of
NaN,Infinityand-Infinityvalues of Postgres'NUMERICcolums with the following logic:for bound
NUMERIC(p,s)columns:pg_numeric_nan_as_nullis enabled (default:TRUE) -NULLis returned onNaNvalueNUMERIC(p,s)columns cannot holdInfinityor-Infinityvaluesfor unbound
NUMERICcolumns:pg_numeric_as_varcharis enabled (default:FALSE) - then aVARCHARrepresentation is returned asNaN,Infinityor-InfinitystringDOUBLEvalue is returned holding DuckDB-nativeNaN,Infinityor-Infinitydouble numberTesting: new test is added with an out-of-bound coverage of both options and of all
NUMERICstorage types.Ref: duckdb/duckdb#23971