You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: SM Black Boxed Queries.md
+17-17Lines changed: 17 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -30,13 +30,13 @@ There is one problem with this query and usage pattern, however. The *string_dat
30
30
This way, a single string parameter passes an arbitrary number of input pairs (path variable and an associated ID) to the parameterized query. The number of required parameters no longer depends on the input, and the updated code can be black-boxed. The only remaining task is to add a new interface query, *json_object_data*, at the top and add code, converting *json_object_data* input to *string_data* format. The following snippet replaces the original *string_data* block:
31
31
32
32
~~~sql
33
-
json_object_data(json_str) AS (
34
-
VALUES
35
-
('{'||
36
-
'"1":"\\usr\\share\\man\\::bin:etc/mc:", '||
37
-
'"2":"/dev/stderr/:/dev/stdout/"'||
38
-
'}')
39
-
),
33
+
json_object_data(json_str) AS (
34
+
VALUES
35
+
('{'||
36
+
'"1":"\\usr\\share\\man\\::bin:etc/mc:", '||
37
+
'"2":"/dev/stderr/:/dev/stdout/"'||
38
+
'}')
39
+
),
40
40
string_data AS (
41
41
SELECT"key"AS string_id, "value"AS string
42
42
FROM json_object_data AS jd, json_each(jd.json_str)
@@ -48,11 +48,11 @@ Furthermore, *json_object_data* and *string_data* can be collapsed, simplifying
48
48
~~~sql
49
49
string_data AS (
50
50
SELECT"key"AS string_id, "value"AS string FROM json_each(
51
-
'{'||
52
-
'"1":"\\usr\\share\\man\\::bin:etc/mc:", '||
53
-
'"2":"/dev/stderr/:/dev/stdout/"'||
54
-
'}'
55
-
)
51
+
'{'||
52
+
'"1":"\\usr\\share\\man\\::bin:etc/mc:", '||
53
+
'"2":"/dev/stderr/:/dev/stdout/"'||
54
+
'}'
55
+
)
56
56
),
57
57
~~~
58
58
@@ -63,11 +63,11 @@ WITH
63
63
params(sep, path_sep) AS (VALUES (':', '\/')),
64
64
string_data AS (
65
65
SELECT"key"AS string_id, "value"AS string FROM json_each(
0 commit comments