Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 73c8e85

Browse files
committed
Avoid using platform-dependent floats in test case.
The number of decimals printed for floats varied in this test case, as noted by several buildfarm members. There's nothing special about floats and arrays in the code being tested, so replace the floats with numerics to make the output platform-independent.
1 parent e131ba4 commit 73c8e85

File tree

3 files changed

+10
-39
lines changed

3 files changed

+10
-39
lines changed

src/pl/plpython/expected/plpython_types.out

+4-15
Original file line numberDiff line numberDiff line change
@@ -568,24 +568,13 @@ INFO: ([[[1L, 2L, None], [None, 5L, 6L]], [[None, 8L, 9L], [10L, 11L, 12L]]], <
568568
{{{1,2,NULL},{NULL,5,6}},{{NULL,8,9},{10,11,12}}}
569569
(1 row)
570570

571-
CREATE FUNCTION test_type_conversion_array_float4(x float4[]) RETURNS float4[] AS $$
571+
CREATE FUNCTION test_type_conversion_array_numeric(x numeric[]) RETURNS numeric[] AS $$
572572
plpy.info(x, type(x))
573573
return x
574574
$$ LANGUAGE plpythonu;
575-
SELECT * FROM test_type_conversion_array_float4(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float4[]);
576-
INFO: ([[[1.2000000476837158, 2.299999952316284, None], [None, 5.699999809265137, 6.800000190734863]], [[None, 8.899999618530273, 9.345000267028809], [10.123000144958496, 11.456000328063965, 12.676799774169922]]], <type 'list'>)
577-
test_type_conversion_array_float4
578-
------------------------------------------------------------------------------
579-
{{{1.2,2.3,NULL},{NULL,5.7,6.8}},{{NULL,8.9,9.345},{10.123,11.456,12.6768}}}
580-
(1 row)
581-
582-
CREATE FUNCTION test_type_conversion_array_float8(x float8[]) RETURNS float8[] AS $$
583-
plpy.info(x, type(x))
584-
return x
585-
$$ LANGUAGE plpythonu;
586-
SELECT * FROM test_type_conversion_array_float8(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float8[]);
587-
INFO: ([[[1.2, 2.3, None], [None, 5.7, 6.8]], [[None, 8.9, 9.345], [10.123, 11.456, 12.6768]]], <type 'list'>)
588-
test_type_conversion_array_float8
575+
SELECT * FROM test_type_conversion_array_numeric(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::numeric[]);
576+
INFO: ([[[Decimal('1.2'), Decimal('2.3'), None], [None, Decimal('5.7'), Decimal('6.8')]], [[None, Decimal('8.9'), Decimal('9.345')], [Decimal('10.123'), Decimal('11.456'), Decimal('12.6768')]]], <type 'list'>)
577+
test_type_conversion_array_numeric
589578
------------------------------------------------------------------------------
590579
{{{1.2,2.3,NULL},{NULL,5.7,6.8}},{{NULL,8.9,9.345},{10.123,11.456,12.6768}}}
591580
(1 row)

src/pl/plpython/expected/plpython_types_3.out

+4-15
Original file line numberDiff line numberDiff line change
@@ -568,24 +568,13 @@ INFO: ([[[1, 2, None], [None, 5, 6]], [[None, 8, 9], [10, 11, 12]]], <class 'li
568568
{{{1,2,NULL},{NULL,5,6}},{{NULL,8,9},{10,11,12}}}
569569
(1 row)
570570

571-
CREATE FUNCTION test_type_conversion_array_float4(x float4[]) RETURNS float4[] AS $$
571+
CREATE FUNCTION test_type_conversion_array_numeric(x numeric[]) RETURNS numeric[] AS $$
572572
plpy.info(x, type(x))
573573
return x
574574
$$ LANGUAGE plpython3u;
575-
SELECT * FROM test_type_conversion_array_float4(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float4[]);
576-
INFO: ([[[1.2000000476837158, 2.299999952316284, None], [None, 5.699999809265137, 6.800000190734863]], [[None, 8.899999618530273, 9.345000267028809], [10.123000144958496, 11.456000328063965, 12.676799774169922]]], <class 'list'>)
577-
test_type_conversion_array_float4
578-
------------------------------------------------------------------------------
579-
{{{1.2,2.3,NULL},{NULL,5.7,6.8}},{{NULL,8.9,9.345},{10.123,11.456,12.6768}}}
580-
(1 row)
581-
582-
CREATE FUNCTION test_type_conversion_array_float8(x float8[]) RETURNS float8[] AS $$
583-
plpy.info(x, type(x))
584-
return x
585-
$$ LANGUAGE plpython3u;
586-
SELECT * FROM test_type_conversion_array_float8(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float8[]);
587-
INFO: ([[[1.2, 2.3, None], [None, 5.7, 6.8]], [[None, 8.9, 9.345], [10.123, 11.456, 12.6768]]], <class 'list'>)
588-
test_type_conversion_array_float8
575+
SELECT * FROM test_type_conversion_array_numeric(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::numeric[]);
576+
INFO: ([[[Decimal('1.2'), Decimal('2.3'), None], [None, Decimal('5.7'), Decimal('6.8')]], [[None, Decimal('8.9'), Decimal('9.345')], [Decimal('10.123'), Decimal('11.456'), Decimal('12.6768')]]], <class 'list'>)
577+
test_type_conversion_array_numeric
589578
------------------------------------------------------------------------------
590579
{{{1.2,2.3,NULL},{NULL,5.7,6.8}},{{NULL,8.9,9.345},{10.123,11.456,12.6768}}}
591580
(1 row)

src/pl/plpython/sql/plpython_types.sql

+2-9
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,12 @@ $$ LANGUAGE plpythonu;
247247

248248
SELECT * FROM test_type_conversion_array_int8(ARRAY[[[1,2,NULL],[NULL,5,6]],[[NULL,8,9],[10,11,12]]]::int8[]);
249249

250-
CREATE FUNCTION test_type_conversion_array_float4(x float4[]) RETURNS float4[] AS $$
250+
CREATE FUNCTION test_type_conversion_array_numeric(x numeric[]) RETURNS numeric[] AS $$
251251
plpy.info(x, type(x))
252252
return x
253253
$$ LANGUAGE plpythonu;
254254

255-
SELECT * FROM test_type_conversion_array_float4(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float4[]);
256-
257-
CREATE FUNCTION test_type_conversion_array_float8(x float8[]) RETURNS float8[] AS $$
258-
plpy.info(x, type(x))
259-
return x
260-
$$ LANGUAGE plpythonu;
261-
262-
SELECT * FROM test_type_conversion_array_float8(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::float8[]);
255+
SELECT * FROM test_type_conversion_array_numeric(ARRAY[[[1.2,2.3,NULL],[NULL,5.7,6.8]],[[NULL,8.9,9.345],[10.123,11.456,12.6768]]]::numeric[]);
263256

264257
CREATE FUNCTION test_type_conversion_array_date(x date[]) RETURNS date[] AS $$
265258
plpy.info(x, type(x))

0 commit comments

Comments
 (0)