Last active
September 23, 2024 05:38
-
-
Save kyu08/a751344fd76d4e50208164378a822dc1 to your computer and use it in GitHub Desktop.
Spannerのテストデータ生成スクリプト
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
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| "github.com/google/uuid" | |
| ) | |
| func main() { | |
| head := "INSERT INTO LogEntries (CompanyId, UserId, Timestamp, EntryShardId, LogEntry) VALUES" | |
| fmt.Printf("%s\n", head) | |
| companies := []string{"amazon", "microsoft", "google", "meta", "apple"} | |
| baseTime := time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC) | |
| employeeCount := 20 | |
| shardCount := 10 | |
| format := "2006-01-02T15:04:05.000000000Z" | |
| for shardID := range shardCount { | |
| for _, company := range companies { | |
| for employeeNum := range employeeCount { | |
| fmt.Printf("('%v', '%s', '%s', %v, ''),\n", company, uuid.New().String(), baseTime.Add(time.Duration(employeeNum)*time.Second).Format(format), shardID) | |
| // 最後の行の余分なカンマは人間が消す。 | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment