Skip to content

Commit

Permalink
feat: generate statement names with format cli-date-time-uuid (#2601)
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickPferr authored Feb 12, 2024
1 parent 5c09612 commit 26f02cc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions pkg/flink/internal/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func tokenRefreshFunc() error {
return nil
}

func (s *StoreTestSuite) TestGenerateStatementName() {
statementRegex := `^cli-\d{4}-\d{2}-\d{2}-\d{6}-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$`
for i := 0; i < 10; i++ {
s.Require().Regexp(statementRegex, types.GenerateStatementName())
}
}

func TestStoreProcessLocalStatement(t *testing.T) {
// Create a new store
client := ccloudv2.NewFlinkGatewayClient("url", "userAgent", false, "authToken")
Expand Down
13 changes: 11 additions & 2 deletions pkg/flink/types/statement.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package types

import "github.com/google/uuid"
import (
"fmt"
"time"

"github.com/google/uuid"
)

func GenerateStatementName() string {
return uuid.New().String()[:18]
clientName := "cli"
date := time.Now().Format("2006-01-02")
localTime := time.Now().Format("150405")
id := uuid.New().String()
return fmt.Sprintf("%s-%s-%s-%s", clientName, date, localTime, id)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
creation_date: 2023-01-01T00:00:00Z
name: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}
name: cli-\d{4}-\d{2}-\d{2}-\d{6}-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}
statement: INSERT \* INTO table;
compute_pool: lfcp-123456
status: PENDING

0 comments on commit 26f02cc

Please sign in to comment.