mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-15 00:56:54 +08:00
Improved avg test
This commit is contained in:
@@ -2,7 +2,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use PostgresNode;
|
use PostgresNode;
|
||||||
use TestLib;
|
use TestLib;
|
||||||
use Test::More tests => 4;
|
use Test::More tests => 5;
|
||||||
|
|
||||||
# Initialize node
|
# Initialize node
|
||||||
my $node = get_new_node('node');
|
my $node = get_new_node('node');
|
||||||
@@ -25,3 +25,12 @@ like($avg, qr/,3\.5/);
|
|||||||
# Test explain
|
# Test explain
|
||||||
my $explain = $node->safe_psql("postgres", "EXPLAIN SELECT AVG(v) FROM tst;");
|
my $explain = $node->safe_psql("postgres", "EXPLAIN SELECT AVG(v) FROM tst;");
|
||||||
like($explain, qr/Partial Aggregate/);
|
like($explain, qr/Partial Aggregate/);
|
||||||
|
|
||||||
|
# Test matches real
|
||||||
|
$node->safe_psql("postgres", "CREATE TABLE tst2 (r real, v vector(1));");
|
||||||
|
$node->safe_psql("postgres",
|
||||||
|
"INSERT INTO tst2 SELECT t.r, ARRAY[t.r] FROM (SELECT random() AS r FROM generate_series(1, 1000000) t0) t;"
|
||||||
|
);
|
||||||
|
my $expected = $node->safe_psql("postgres", "SELECT AVG(r)::float4 FROM tst2;");
|
||||||
|
$avg = $node->safe_psql("postgres", "SELECT AVG(v) FROM tst2;");
|
||||||
|
is($avg, "[$expected]");
|
||||||
|
|||||||
Reference in New Issue
Block a user