-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
196 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"match_time": "2000-01-01", "match_id": 1, "player_id": "Alice", "score": 100} | ||
{"match_time": "2000-01-01", "match_id": 1, "player_id": "Bob", "score": 80} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"match_time": "2000-01-02", "match_id": 2, "player_id": "Alice", "score": 70} | ||
{"match_time": "2000-01-02", "match_id": 2, "player_id": "Charlie", "score": 90} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"match_time": "2000-01-03", "match_id": 3, "player_id": "Bob", "score": 60} | ||
{"match_time": "2000-01-03", "match_id": 3, "player_id": "Charlie", "score": 110} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
kamu init --exists-ok | ||
kamu add . -r | ||
|
||
for file in `ls ./data/ | sort -g`; do | ||
echo "kamu ingest player-scores data/$file" | ||
kamu ingest player-scores data/$file | ||
|
||
echo "kamu pull leaderboard" | ||
kamu pull leaderboard | ||
done |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
kind: DatasetSnapshot | ||
version: 1 | ||
content: | ||
name: leaderboard | ||
kind: Derivative | ||
metadata: | ||
- kind: SetTransform | ||
inputs: | ||
- datasetRef: player-scores | ||
alias: player_scores | ||
transform: | ||
kind: Sql | ||
engine: risingwave | ||
queries: | ||
- alias: leaderboard | ||
# Note we are using explicit `crate materialized view` statement below | ||
# because RW does not currently support Top-N queries directly on sinks. | ||
# | ||
# Note `partition by 1` is currently required by RW engine | ||
# See: https://docs.risingwave.com/docs/current/window-functions/#syntax | ||
query: | | ||
create materialized view leaderboard as | ||
select | ||
* | ||
from ( | ||
select | ||
row_number() over (partition by 1 order by score desc) as place, | ||
match_time, | ||
match_id, | ||
player_id, | ||
score | ||
from player_scores | ||
) | ||
where place <= 2 | ||
- query: | | ||
select * from leaderboard | ||
- kind: SetVocab | ||
eventTimeColumn: match_time |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
kind: DatasetSnapshot | ||
version: 1 | ||
content: | ||
name: player-scores | ||
kind: Root | ||
metadata: | ||
- kind: AddPushSource | ||
sourceName: default | ||
read: | ||
kind: NdJson | ||
schema: | ||
- "match_time TIMESTAMP" | ||
- "match_id BIGINT" | ||
- "player_id STRING" | ||
- "score BIGINT" | ||
merge: | ||
kind: Ledger | ||
primaryKey: | ||
- match_id | ||
- player_id | ||
- kind: SetVocab | ||
eventTimeColumn: match_time |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.