Last active
January 21, 2026 14:53
-
-
Save fithisux/05fa36d8325c13afdea520b878e0895b to your computer and use it in GitHub Desktop.
Json generalization
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) | |
| WINDOW tracked_id_timeline as (PARTITION BY object_id ORDER BY sample_id) | |
| ) | |
| select | |
| * except (rr, prev_xxx, xxx) | |
| from | |
| annotated_data | |
| where | |
| rr = 1 | |
| or not equal_null(xxx, prev_xxx) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment