Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77b7e77

Browse files
authored
Merge pull request#24 from postgrespro/PGPRO-6448
[PGPRO-6448] Function unnest renamed to vops_unnest
2 parents975ebfd +ff8e5c5 commit77b7e77

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
lines changed

‎README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ There are also two important restrictions:
415415
Example of using window functions with
416416
VOPS:
417417

418-
selectunnest(t.*) from (select mcount(*) over w,mcount(x) over w,msum(x) over w,mavg(x) over w,mmin(x) over w,mmax(x) over w,x - lag(x) over w
418+
selectvops_unnest(t.*) from (select mcount(*) over w,mcount(x) over w,msum(x) over w,mavg(x) over w,mmin(x) over w,mmax(x) over w,x - lag(x) over w
419419
from v window w as (rows between unbounded preceding and current row)) t;
420420

421421
###<spanid="indexes">Using indexes</span>
@@ -571,16 +571,16 @@ It accepts name of target VOPS table, path to CSV file, optional
571571
separator (default is ',') and number of lines in CSV header (no header
572572
by default). The function returns number of imported rows.
573573

574-
###<spanid="unnest">Back to normal tuples</span>
574+
###<spanid="vops_unnest">Back to normal tuples</span>
575575

576576
A query from VOPS projection returns set of tiles. Output function of
577577
tile type is able to print content of the tile. But in some cases it is
578578
preferable to transfer result to normal (horizontal) format where each
579-
tuple represents one record. It can be done using`unnest`
579+
tuple represents one record. It can be done using`vops_unnest`
580580
function:
581581

582-
postgres=# selectunnest(l.*) from vops_lineitem l where filter(l_shipdate <= '1998-12-01'::date) limit 3;
583-
unnest
582+
postgres=# selectvops_unnest(l.*) from vops_lineitem l where filter(l_shipdate <= '1998-12-01'::date) limit 3;
583+
vops_unnest
584584
---------------------------------------
585585
(1996-03-13,17,33078.9,0.04,0.02,N,O)
586586
(1996-04-12,36,38306.2,0.09,0.06,N,O)
@@ -589,18 +589,18 @@ tuple represents one record. It can be done using `unnest`
589589

590590
###<spanid="fdw">Back to normal tables</span>
591591

592-
As it was mentioned in previous section,`unnest` function can scatter
593-
records with VOPS types into normal records with scalar types. So it is
594-
possible to use this records in arbitrary SQL queries. But there are two
595-
problems withunnest function:
592+
As it was mentioned in previous section,`vops_unnest` function can
593+
scatterrecords with VOPS types into normal records with scalar types.
594+
So it ispossible to use this records in arbitrary SQL queries. But
595+
there are twoproblems withvops_unnest function:
596596

597597
1. It is not convenient to use. This function has no static knowledge
598598
about the format of output record and this is why programmer has to
599599
specify it manually, if here wants to decompose this record.
600600
2. PostgreSQL optimizer has completely no knowledge on result of
601-
transformation performed byunnest() function. This is why it is not
602-
able to choose optimal query execution plan for data retrieved from
603-
VOPS table.
601+
transformation performed byvops_unnest() function. This is why it
602+
is notable to choose optimal query execution plan for data
603+
retrieved fromVOPS table.
604604

605605
Fortunately Postgres provides solution for both of this problem: foreign
606606
data wrappers (FDW). In our case data is not really "foreign": it is

‎expected/test.out

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ select populate(destination:='v'::regclass, source:='s'::regclass);
99
6
1010
(1 row)
1111

12-
selectunnest(v.*) from v where x > 1;
13-
unnest
14-
--------
12+
selectvops_unnest(v.*) from v where x > 1;
13+
vops_unnest
14+
-------------
1515
(2)
1616
(3)
1717
(4)
@@ -71,8 +71,8 @@ select count(*) from v where coalesce(x, 0.0::float8::vops_float4) >= 0;
7171
6
7272
(1 row)
7373

74-
selectunnest(t.*) from (select mcount(*) over w,mcount(x) over w,msum(x) over w,mavg(x) over w,mmin(x) over w,mmax(x) over w,x - lag(x) over w from v window w as (rows between unbounded preceding and current row)) t;
75-
unnest
74+
selectvops_unnest(t.*) from (select mcount(*) over w,mcount(x) over w,msum(x) over w,mavg(x) over w,mmin(x) over w,mmax(x) over w,x - lag(x) over w from v window w as (rows between unbounded preceding and current row)) t;
75+
vops_unnest
7676
-------------------
7777
(1,1,1,1,1,1,)
7878
(2,2,3,1.5,1,2,1)
@@ -92,9 +92,9 @@ select populate(destination:='v2'::regclass, source:='s2'::regclass,sort:='id');
9292
100
9393
(1 row)
9494

95-
selectunnest(t.*) from (select msum(x,10) over (order by first(id)) from v2) t;
96-
unnest
97-
--------
95+
selectvops_unnest(t.*) from (select msum(x,10) over (order by first(id)) from v2) t;
96+
vops_unnest
97+
-------------
9898
(1)
9999
(3)
100100
(6)

‎sql/test.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ create table s(x real);
44
createtablev(x vops_float4);
55
insert into svalues(1.0),(2.0),(null),(3.0),(null),(4.0);
66
select populate(destination:='v'::regclass, source:='s'::regclass);
7-
selectunnest(v.*)from vwhere x>1;
7+
selectvops_unnest(v.*)from vwhere x>1;
88
select countall(*)from vwhere xis not null;
99
selectcount(*)from vwhere x isnull;
1010
selectcount(*)from vwhere xis not null;
@@ -14,14 +14,14 @@ select count(*),count(x),sum(x),avg(x),min(x),max(x),variance(x),var_pop(x),var_
1414
selectcount(*),count(x),sum(x),avg(x),min(x),max(x),variance(x),var_pop(x),var_samp(x),stddev(x),stddev_pop(x),stddev_samp(x)from swhere x>1.0;
1515
selectcount(*)from vwhere ifnull(x,0)>=0;
1616
selectcount(*)from vwhere coalesce(x,0.0::float8::vops_float4)>=0;
17-
selectunnest(t.*)from (select mcount(*) over w,mcount(x) over w,msum(x) over w,mavg(x) over w,mmin(x) over w,mmax(x) over w,x- lag(x) over wfrom v window was (rows between unbounded precedingand current row)) t;
17+
selectvops_unnest(t.*)from (select mcount(*) over w,mcount(x) over w,msum(x) over w,mavg(x) over w,mmin(x) over w,mmax(x) over w,x- lag(x) over wfrom v window was (rows between unbounded precedingand current row)) t;
1818

1919
createtables2(x float8, idserial);
2020
insert into s2(select generate_series(1,100));
2121
createtablev2(x vops_float8, id vops_int4);
2222
select populate(destination:='v2'::regclass, source:='s2'::regclass,sort:='id');
2323

24-
selectunnest(t.*)from (select msum(x,10) over (order by first(id))from v2) t;
24+
selectvops_unnest(t.*)from (select msum(x,10) over (order by first(id))from v2) t;
2525
selectsum(x) over (order by id rows between9 precedingand current row)from s2;
2626

2727
setvops.auto_substitute_projections=on;

‎tpch2.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,17 @@ select
118118
count(*),
119119
sum(l_extendedprice* (1-l_discount))as revenue
120120
from
121-
(select c.*from vcustomer vc,unnest(vc.*) c(c_custkey int4,c_nationkey int4,c_acctbalreal)) c1
121+
(select c.*from vcustomer vc,vops_unnest(vc.*) c(c_custkey int4,c_nationkey int4,c_acctbalreal)) c1
122122
join
123-
(select o.*from vorders vo,unnest(vo.*) o(o_orderkey int4,o_custkey int4,o_orderstatus"char",
123+
(select o.*from vorders vo,vops_unnest(vo.*) o(o_orderkey int4,o_custkey int4,o_orderstatus"char",
124124
o_totalpricereal,o_orderdatedate,o_shippriority int4)
125125
wherevo.o_orderdate>='1996-01-01'::dateandvo.o_orderdate<'1997-01-01'::date) o1
126126
on c_custkey= o_custkey
127127
join
128-
(select l.*from vlineitem vl,unnest(vl.*) l(l_suppkey int4,l_orderkey int4,l_partkey int4,l_shipdatedate,l_quantity float4,
128+
(select l.*from vlineitem vl,vops_unnest(vl.*) l(l_suppkey int4,l_orderkey int4,l_partkey int4,l_shipdatedate,l_quantity float4,
129129
l_extendedprice float4,l_discount float4,l_tax float4,l_returnflag"char",l_linestatus"char")) l1on l_orderkey= o_orderkey
130130
join
131-
(select s.*from vsupplier vs,unnest(vs.*) s(s_suppkey int4,s_nationkey int4,s_acctbalreal)) s1on l_suppkey= s_suppkey
131+
(select s.*from vsupplier vs,vops_unnest(vs.*) s(s_suppkey int4,s_nationkey int4,s_acctbalreal)) s1on l_suppkey= s_suppkey
132132
join nationon c_nationkey= n_nationkey
133133
join regionon n_regionkey= r_regionkey
134134
where

‎vops--1.0.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* contrib/vops/vops.sql*/
1+
/* contrib/vops/vops--1.0.sql*/
22

33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use"create extension vops" to load this file. \quit
@@ -3453,7 +3453,7 @@ create function import(destination regclass, csv_path cstring, separator cstring
34533453
createtypevops_aggregatesas(group_by int8, count int8, aggs float8[]);
34543454
createfunctionreduce(bigint) returns setof vops_aggregatesas'MODULE_PATHNAME','vops_reduce' language C parallel safe strict immutable;
34553455

3456-
createfunctionunnest(anyelement) returns setof recordas'MODULE_PATHNAME','vops_unnest' language C parallel safe strict immutable;
3456+
createfunctionvops_unnest(anyelement) returns setof recordas'MODULE_PATHNAME','vops_unnest' language C parallel safe strict immutable;
34573457

34583458
create cast (vops_boolas bool) with function filter(vops_bool)AS IMPLICIT;
34593459

‎vops.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h1>Vectorized Operations (VOPS)</h1>
1515
<li><ahref="#window">Vector window functions</a></li>
1616
<li><ahref="#indexes">Using indexes</a></li>
1717
<li><ahref="#populating">Preparing data for VOPS</a></li>
18-
<li><ahref="#unnest">Back to normal tuples</a></li>
18+
<li><ahref="#vops_unnest">Back to normal tuples</a></li>
1919
<li><ahref="#fdw">Back to normal tables</a></li>
2020
</ul>
2121
<li><ahref="#transform">Standard SQL query transformation</a></li>
@@ -389,7 +389,7 @@ <h3><a name="window">Vector window functions</a></h3>
389389
Example of using window functions with VOPS:
390390
</p>
391391
<pre>
392-
selectunnest(t.*) from (select mcount(*) over w,mcount(x) over w,msum(x) over w,mavg(x) over w,mmin(x) over w,mmax(x) over w,x - lag(x) over w
392+
selectvops_unnest(t.*) from (select mcount(*) over w,mcount(x) over w,msum(x) over w,mavg(x) over w,mmin(x) over w,mmax(x) over w,x - lag(x) over w
393393
from v window w as (rows between unbounded preceding and current row)) t;
394394
</pre>
395395

@@ -562,15 +562,15 @@ <h3><a name="populating">Preparing data for VOPS</a></h3>
562562
(no header by default). The function returns number of imported rows.
563563
</p>
564564

565-
<h3><aname="unnest">Back to normal tuples</a></h3>
565+
<h3><aname="vops_unnest">Back to normal tuples</a></h3>
566566
<p>
567567
A query from VOPS projection returns set of tiles. Output function of tile type is able to print content of the tile.
568568
But in some cases it is preferable to transfer result to normal (horizontal) format where each tuple represents one record.
569-
It can be done using<code>unnest</code> function:
569+
It can be done using<code>vops_unnest</code> function:
570570
</p>
571571
<pre>
572-
postgres=# selectunnest(l.*) from vops_lineitem l where filter(l_shipdate &lt;= '1998-12-01'::date) limit 3;
573-
unnest
572+
postgres=# selectvops_unnest(l.*) from vops_lineitem l where filter(l_shipdate &lt;= '1998-12-01'::date) limit 3;
573+
vops_unnest
574574
---------------------------------------
575575
(1996-03-13,17,33078.9,0.04,0.02,N,O)
576576
(1996-04-12,36,38306.2,0.09,0.06,N,O)
@@ -581,14 +581,14 @@ <h3><a name="unnest">Back to normal tuples</a></h3>
581581

582582
<h3><aname="fdw">Back to normal tables</a></h3>
583583
<p>
584-
As it was mentioned in previous section,<code>unnest</code> function can scatter records with VOPS types into normal records with scalar types.
584+
As it was mentioned in previous section,<code>vops_unnest</code> function can scatter records with VOPS types into normal records with scalar types.
585585
So it is possible to use this records in arbitrary SQL queries.
586-
But there are two problems withunnest function:
586+
But there are two problems withvops_unnest function:
587587
</p>
588588
<ol>
589589
<li>It is not convenient to use. This function has no static knowledge about the format of output record and this is why programmer has to specify it manually,
590590
if here wants to decompose this record.</li>
591-
<li>PostgreSQL optimizer has completely no knowledge on result of transformation performed byunnest() function.
591+
<li>PostgreSQL optimizer has completely no knowledge on result of transformation performed byvops_unnest() function.
592592
This is why it is not able to choose optimal query execution plan for data retrieved from VOPS table.</li>
593593
</ol>
594594
<p>

‎vops_fdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ postgresAcquireSampleRowsFunc(Relation relation, int elevel,
15091509
}
15101510
appendStringInfoString(&sql," FROM ");
15111511
vopsDeparseRelation(&sql,relation);
1512-
appendStringInfo(&sql," t,unnest(t) r(%s)",record.data);
1512+
appendStringInfo(&sql," t,vops_unnest(t) r(%s)",record.data);
15131513

15141514
portal=SPI_cursor_open_with_args(NULL,sql.data,0,NULL,NULL,NULL, true,0);
15151515

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp