Skip to content

Commit f3ad42d

Browse files
committed
Update MP CREATE Paths.md
1 parent 82383ba commit f3ad42d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

MP CREATE Paths.md

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The CREATE script incorporates the following components:
1616

1717
~~~sql
1818
WITH
19+
------------------------------ PROLOGUE ------------------------------
1920
json_ops(ops) AS (
2021
VALUES
2122
(json(
@@ -34,6 +35,8 @@ WITH
3435
json_extract(value, '$.path_new') AS path_new
3536
FROM json_ops AS jo, json_each(jo.ops) AS terms
3637
),
38+
/********************************************************************/
39+
--------------------------- ANCESTOR LIST ----------------------------
3740
levels AS (
3841
SELECT opid, path_new AS path, length(path_new) - length(replace(path_new, '/', '')) AS depth
3942
FROM base_ops
@@ -54,6 +57,7 @@ WITH
5457
GROUP BY asc_path
5558
ORDER BY opid, asc_path
5659
),
60+
/********************************************************************/
5761
path_terms AS (
5862
SELECT
5963
row_number() OVER (ORDER BY opid, asc_path) AS counter,
@@ -62,6 +66,7 @@ WITH
6266
LEFT JOIN categories AS cats ON asc_path = cats.path
6367
WHERE cats.ascii_id IS NULL
6468
),
69+
------------------------- ASCII ID GENERATOR -------------------------
6570
id_counts(id_counter) AS (SELECT count(*) FROM path_terms),
6671
json_templates AS (SELECT '[' || replace(hex(zeroblob(id_counter*8/2-1)), '0', '0,') || '0,0]' AS json_template FROM id_counts),
6772
char_templates(char_template) AS (VALUES ('-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_')),
@@ -82,6 +87,7 @@ WITH
8287
(unicode(substr(ascii_id, 8, 1)) << 8*0) AS bin_id
8388
FROM ascii_ids
8489
),
90+
/********************************************************************/
8591
new_nodes AS (
8692
SELECT bin_id AS id, asc_name AS name, asc_prefix AS prefix
8793
FROM path_terms, ids USING (counter)

0 commit comments

Comments
 (0)