Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
|
|
@ -0,0 +1 @@
|
|||
select j as i, i as j, value from A;
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
create or replace table A (i integer, j integer, value float );
|
||||
insert into A values
|
||||
(1, 1, 1),
|
||||
(1, 2, 2),
|
||||
(1, 3, 3),
|
||||
(2, 1, 2),
|
||||
(2, 2, 5),
|
||||
(2, 3, 7);
|
||||
|
||||
# transposition
|
||||
create or replace table AT as
|
||||
(select j as i, i as j, value from A);
|
||||
|
||||
.print The matrix-like representation of A:
|
||||
create or replace table AMatrix as (pivot A on j using max(value) order by i);
|
||||
from AMatrix;
|
||||
|
||||
.print Convert the matrix-like representation back to the (i,j,value) representation:
|
||||
unpivot AMatrix on columns('^[1-9]') into name j VALUE value;
|
||||
|
||||
.print The matrix-like representation of "A transpose":
|
||||
pivot AT on j using max(value) order by i;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Note that if the input is not rectangular, the output might be lossy.
|
||||
create or replace function transpose(lst) as (
|
||||
select list_transform( range(1, 1+length(lst[1])),
|
||||
j -> list_transform(range(1, length(lst)+1),
|
||||
i -> lst[i][j]) ));
|
||||
Loading…
Add table
Add a link
Reference in a new issue