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
With a sliding window function, we should be able to do "adjacency" searches in parabible. This will not force an order of wids (not a sequence search), but it is a useful first step. The relevant "WINDOW" function docs for clickhouse are pasted below. First, though, here's a mocked up query that does something useful:
select * from (
SELECT
groupArray(rid) OVER w1 AS rids,
groupArray(wid) OVER w1 AS wids,
groupArray(text) OVER w1 AS words,
groupArray(lexeme) OVER w1 AS lexemes,
groupArrayIf(lexeme, lexeme='ἐκκλησία') OVER w1 AS w1,
groupArrayIf(lexeme, lexeme='παροικέω') OVER w1 AS w2
FROM word_features
WINDOW
w1 AS (PARTITION BY module_id ORDER BY wid ASC Rows BETWEEN 2 PRECEDING AND 2 FOLLOWING)
)
where length(w1) > 0 and length(w2) > 0
LIMIT 10
-- first_value and last_value respect the frameSELECT
groupArray(value) OVER w1 AS frame_values_1,
first_value(value) OVER w1 AS first_value_1,
last_value(value) OVER w1 AS last_value_1,
groupArray(value) OVER w2 AS frame_values_2,
first_value(value) OVER w2 AS first_value_2,
last_value(value) OVER w2 AS last_value_2
FROM wf_frame
WINDOW
w1 AS (PARTITION BY part_key ORDER BY order ASC),
w2 AS (PARTITION BY part_key ORDER BY order ASC Rows BETWEEN 1 PRECEDING AND CURRENT ROW)
ORDER BY
part_key ASC,
value ASC;
┌─frame_values_1─┬─first_value_1─┬─last_value_1─┬─frame_values_2─┬─first_value_2─┬─last_value_2─┐
│ [1] │ 1 │ 1 │ [1] │ 1 │ 1 │
│ [1,2] │ 1 │ 2 │ [1,2] │ 1 │ 2 │
│ [1,2,3] │ 1 │ 3 │ [2,3] │ 2 │ 3 │
│ [1,2,3,4] │ 1 │ 4 │ [3,4] │ 3 │ 4 │
│ [1,2,3,4,5] │ 1 │ 5 │ [4,5] │ 4 │ 5 │
└────────────────┴───────────────┴──────────────┴────────────────┴───────────────┴──────────────┘
-- second value within the frameSELECT
groupArray(value) OVER w1 AS frame_values_1,
nth_value(value, 2) OVER w1 AS second_value
FROM wf_frame
WINDOW w1 AS (PARTITION BY part_key ORDER BY order ASC Rows BETWEEN 3 PRECEDING AND CURRENT ROW)
ORDER BY
part_key ASC,
value ASC
┌─frame_values_1─┬─second_value─┐
│ [1] │ 0 │
│ [1,2] │ 2 │
│ [1,2,3] │ 2 │
│ [1,2,3,4] │ 2 │
│ [2,3,4,5] │ 3 │
└────────────────┴──────────────┘
-- second value within the frame + Null for missing valuesSELECT
groupArray(value) OVER w1 AS frame_values_1,
nth_value(toNullable(value), 2) OVER w1 AS second_value
FROM wf_frame
WINDOW w1 AS (PARTITION BY part_key ORDER BY order ASC Rows BETWEEN 3 PRECEDING AND CURRENT ROW)
ORDER BY
part_key ASC,
value ASC
┌─frame_values_1─┬─second_value─┐
│ [1] │ ᴺᵁᴸᴸ │
│ [1,2] │ 2 │
│ [1,2,3] │ 2 │
│ [1,2,3,4] │ 2 │
│ [2,3,4,5] │ 3 │
└────────────────┴──────────────┘
```sql
The text was updated successfully, but these errors were encountered:
With a sliding window function, we should be able to do "adjacency" searches in parabible. This will not force an order of wids (not a sequence search), but it is a useful first step. The relevant "WINDOW" function docs for clickhouse are pasted below. First, though, here's a mocked up query that does something useful:
The text was updated successfully, but these errors were encountered: