-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #426 from jjrom/I419-rewrite-facet
Remove dead code
- Loading branch information
Showing
4 changed files
with
51 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
-- Step 1: Create the new table | ||
CREATE TABLE resto.catalog_test ( | ||
id TEXT, | ||
description TEXT | ||
); | ||
|
||
-- Step 2 & 3: Recursive query and insert into new table | ||
WITH RECURSIVE cte AS ( | ||
-- Anchor member: Select the root nodes | ||
SELECT | ||
id AS original_id, | ||
id AS newid, | ||
id AS hashtag, | ||
description, | ||
pid | ||
FROM | ||
resto.facet | ||
WHERE | ||
pid = 'root' | ||
|
||
UNION ALL | ||
|
||
-- Recursive member: Join with child nodes | ||
SELECT | ||
child.id AS original_id, | ||
CONCAT(cte.newid, '/', child.id) AS newid, | ||
child.id as hashtag, | ||
child.description, | ||
child.pid | ||
FROM | ||
resto.facet AS child | ||
INNER JOIN cte ON cte.original_id = child.pid | ||
) | ||
|
||
-- Insert the final results into the new table | ||
-- INSERT INTO resto.catalog_test (id, description) | ||
SELECT | ||
newid, | ||
title, | ||
description, | ||
level, | ||
counters, | ||
owner, | ||
now() as created, | ||
links, | ||
visibility, | ||
rtype, | ||
hashtag | ||
FROM | ||
cte; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters