diff --git a/go/internal/feast/onlinestore/cassandraonlinestore.go b/go/internal/feast/onlinestore/cassandraonlinestore.go index 093250f8738..1ae4273432e 100644 --- a/go/internal/feast/onlinestore/cassandraonlinestore.go +++ b/go/internal/feast/onlinestore/cassandraonlinestore.go @@ -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 } diff --git a/go/internal/feast/registry/repoconfig_test.go b/go/internal/feast/registry/repoconfig_test.go index 4d30bf7bca0..8734d590bbf 100644 --- a/go/internal/feast/registry/repoconfig_test.go +++ b/go/internal/feast/registry/repoconfig_test.go @@ -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))) +}