| object_id | sample_id | feature_1 | feature_2 | xxx |
|---|---|---|---|---|
| A1 | 2 | null | null | {} |
| A2 | 3 | null | null | {} |
This file contains hidden or 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
| with annotated_data as ( | |
| SELECT | |
| *, | |
| to_json(struct(* except (object_id, sample_id))) as xxx, | |
| lag(to_json(struct(* except (object_id, sample_id)))) over tracked_id_timeline as prev_xxx, | |
| row_number() over tracked_id_timeline as rr | |
| FROM | |
| VALUES ('A1', 2, 1, 5), ('A1', 1, 1, 5), ('A2', 3, 3, 7), ('A1', 3, 2, 6) tab | |
| (object_id, sample_id, feature_1, feature_2) | |
| WINDOW tracked_id_timeline as (PARTITION BY object_id ORDER BY sample_id) |
This file contains hidden or 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
| %sql | |
| SELECT | |
| *, | |
| to_json(struct(* except (object_id, sample_id))) as xxx | |
| FROM | |
| VALUES ('A1', 2, null, null), ('A2', 3, null, null) tab(object_id, sample_id, feature_1, feature_2) |
| object_id | sample_id | feature_1 | feature_2 |
|---|---|---|---|
| A1 | 1 | 1 | 5 |
| A1 | 3 | 2 | 6 |
| A2 | 3 | 3 | 7 |
This file contains hidden or 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
| %sql | |
| with annotated_data as ( | |
| SELECT | |
| *, | |
| to_json(struct(* except (object_id, sample_id))) as xxx, | |
| lag(to_json(struct(* except (object_id, sample_id)))) over tracked_id_timeline as prev_xxx, | |
| row_number() over tracked_id_timeline as rr | |
| FROM | |
| VALUES ('A1', 2, 1, 5), ('A1', 1, 1, 5), ('A2', 3, 3, 7), ('A1', 3, 2, 6) tab | |
| (object_id, sample_id, feature_1, feature_2) |
| object_id | sample_id | feature_1 | feature_2 | xxx |
|---|---|---|---|---|
| A1 | 2 | 1 | 5 | "{""feature_1"":1,""feature_2"":5}" |
| A1 | 1 | 1 | 5 | "{""feature_1"":1,""feature_2"":5}" |
| A2 | 3 | 3 | 7 | "{""feature_1"":3,""feature_2"":7}" |
| A1 | 3 | 2 | 6 | "{""feature_1"":2,""feature_2"":6}" |
This file contains hidden or 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
| SELECT | |
| *, | |
| to_json(struct(* except (object_id, sample_id))) as xxx | |
| FROM | |
| VALUES ('A1', 2, 1, 5), ('A1', 1, 1, 5), ('A2', 3, 3, 7), ('A1', 3, 2, 6) tab | |
| (object_id, sample_id, feature_1, feature_2) |
| object_id | sample_id | feature_1 | feature_2 |
|---|---|---|---|
| A1 | 1 | null | null |
| A1 | 2 | 1 | 5 |
| A1 | 3 | null | null |
| A2 | 3 | 3 | 7 |
This file contains hidden or 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
| %sql | |
| with annotated_data as ( | |
| SELECT | |
| object_id, | |
| sample_id, | |
| feature_1, | |
| lag(feature_1) OVER tracked_id_timeline as prev_feature_1, | |
| feature_2, | |
| lag(feature_2) OVER tracked_id_timeline prev_feature_2, | |
| row_number() over tracked_id_timeline as rr |
| object_id | sample_id | feature_1 | prev_feature_1 | feature_2 | prev_feature_2 | rr |
|---|---|---|---|---|---|---|
| A1 | 1 | null | null | null | null | 1 |
| A2 | 3 | 3 | null | 7 | null | 1 |
NewerOlder