Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correct type conversion for table name format version #177

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/internal/feast/onlinestore/cassandraonlinestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func NewCassandraOnlineStore(project string, config *registry.RepoConfig, online
tableNameFormatVersion = 1
log.Warn().Msg("table_name_format_version not specified: Using 1 instead")
}
store.tableNameFormatVersion = tableNameFormatVersion.(int)
store.tableNameFormatVersion = int(tableNameFormatVersion.(float64))

return &store, nil
}
Expand Down
46 changes: 46 additions & 0 deletions go/internal/feast/registry/repoconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,49 @@ func TestGetLoggingOptions_InvalidType(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, logging.DefaultOptions, *options)
}

func TestNewRepoConfigForScyllaDBFromJSON(t *testing.T) {
// Create a temporary directory for the test
dir, err := os.MkdirTemp("", "feature_repo_*")
assert.Nil(t, err)
defer func() {
assert.Nil(t, os.RemoveAll(dir))
}()

// Define a JSON string for the test
registry_path := filepath.Join(dir, "data/registry.db")

configJSON := `{
"project": "feature_repo",
"registry": "$REGISTRY_PATH",
"provider": "local",
"online_store": {
"type": "scylladb",
"hosts": ["localhost:9042"],
"key_batch_size": 85,
"table_name_format_version": 2
}
}`

replacements := map[string]string{
"$REGISTRY_PATH": registry_path,
}

// Replace the variables in the JSON string
for variable, replacement := range replacements {
configJSON = strings.ReplaceAll(configJSON, variable, replacement)
}

// Call the function under test
config, _ := NewRepoConfigFromJSON(dir, configJSON)
registryConfig, err := config.GetRegistryConfig()
// Assert that there was no error and that the config was correctly parsed
assert.Nil(t, err)
// assert.Equal(t, "feature_repo", config.Project)
assert.Equal(t, filepath.Join(dir, "data/registry.db"), registryConfig.Path)
assert.Equal(t, "local", config.Provider)
assert.Equal(t, float64(85), config.OnlineStore["key_batch_size"])
assert.Equal(t, float64(2), config.OnlineStore["table_name_format_version"])
assert.Equal(t, int(85), int(config.OnlineStore["key_batch_size"].(float64)))
assert.Equal(t, int(2), int(config.OnlineStore["table_name_format_version"].(float64)))
}
Loading