Skip to content

Can't use gocql 2.0 features with gocql-astra #26

@aar0np

Description

@aar0np

code:

package repository

import (
	"fmt"
	"killrvideo/go-backend-astra-cql/models"

	gocql "github.com/gocql/gocql"
)

type VideoDAL struct {
	DB *gocql.Session
}

func NewVideoDAL(session *gocql.Session) *VideoDAL {
	return &VideoDAL{
		DB: session,
	}
}

func (r *VideoDAL) GetVideo(id gocql.UUID) (*models.Video, error) {
	video := &models.Video{Videoid: id}
	var vector []float32

	err1 := r.DB.Query(
		"SELECT userid, name, description, location, preview_image_location, added_date, content_features FROM videos WHERE videoid = ?",
		id,
	).Scan(&video.Userid, &video.Name, &video.Description, &video.Location, &video.PreviewImageLocation, &video.AddedDate, &vector)

	if err1 != nil {
		return nil, fmt.Errorf("query has failed: %w", err1)
	}

	return video, nil
}

Error handling returns:

{"error":"query has failed: can not unmarshal custom(org.apache.cassandra.db.marshal.VectorType(org.apache.cassandra.db.marshal.FloatType, 384)) into *[]float32"}

Reverting to apache/cassandra-gocql-driver/v2 2.0.0 works, but then I lose the ability to use NewClusterFromURL and have to unzip/access the individual components of the Astra SCB to connect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions