Skip to content

Commit

Permalink
Merge pull request #8 from opt-nc/adriens-patch-1
Browse files Browse the repository at this point in the history
doc(CI) : Cleaner CI
  • Loading branch information
mbarre authored Apr 14, 2024
2 parents 8d88c24 + 66c3d0c commit 1465e7b
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions duck.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-- Load acronyms data
create
or replace table acronyms (
id_acronym VARCHAR NOT NULL, CHECK (id_acronym = UPPER(id_acronym)),
create or replace table acronyms (
id_acronym VARCHAR NOT NULL CHECK (id_acronym = UPPER(id_acronym)),
description VARCHAR UNIQUE
);

Expand All @@ -16,32 +15,46 @@ from
})
) t;

from acronyms;
-- Get a preveiw
from acronyms limit 5;

------------------------------------------------
-- Preserve order of rows

-- Prepare test environment
CREATE SEQUENCE seq_original START 1;
CREATE SEQUENCE seq_sorted START 1;

create or replace temp table orig_table as
select nextval('seq_original') as index,
id_acronym, description from acronyms;
id_acronym,
description
from acronyms;

create or replace temp table sorted_table as
select nextval('seq_sorted') as index,
id_acronym, description
from (select id_acronym, description from acronyms order by id_acronym, description);
id_acronym,
description
from (select id_acronym,
description
from acronyms
-- order by acronym and description
order by id_acronym, description);

-- Check the resulting tables
from orig_table;
from sorted_table;
from orig_table limit 5;
from sorted_table limit 5;

-- Create the table that compares the sorted and original tables columns
create or replace temp table test_sorted(orig_id_acronym varchar, orig_description varchar,
create or replace temp table test_sorted(
orig_id_acronym varchar,
orig_description varchar,
orig_index integer,
sorted_index integer
-- the magic part XD
check(orig_index = sorted_index)
);

-- Populate the comparison table
insert into test_sorted
select
Expand Down

0 comments on commit 1465e7b

Please sign in to comment.