Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
60a3230
Support vector type
lukasz-antoniak Oct 10, 2024
2c39f8e
Vector support tests
lukasz-antoniak Oct 10, 2024
a2ace23
Test vectors of simple types
lukasz-antoniak Oct 10, 2024
0e5ab4b
Support complex vectory subtypes
lukasz-antoniak Oct 10, 2024
f898522
Fix comparison in tests
lukasz-antoniak Oct 11, 2024
abec222
Support vector of UDT types
lukasz-antoniak Oct 11, 2024
7483874
Support vector of UDT types
lukasz-antoniak Oct 11, 2024
2072bad
Alternative to parse custom string
lukasz-antoniak Oct 15, 2024
30b5b49
Support vector of tuples
lukasz-antoniak Oct 16, 2024
8176709
Apply review comments
lukasz-antoniak Oct 16, 2024
bd32b39
Install JDK 11 for C* 4.x
lukasz-antoniak Oct 16, 2024
923e980
Install JDK 11 for C* 4.x
lukasz-antoniak Oct 16, 2024
0a17f00
Trigger Build
lukasz-antoniak Oct 16, 2024
041d9d9
Tune Gossip
lukasz-antoniak Oct 16, 2024
6f421e8
Fix integration tests Github action
lukasz-antoniak Oct 17, 2024
e8d141b
Apply review comments
lukasz-antoniak Oct 28, 2024
971c0b5
Apply review comments
lukasz-antoniak Oct 29, 2024
467c820
Apply review comments
lukasz-antoniak Oct 29, 2024
87dafb1
Revert unnecessary changes
lukasz-antoniak Oct 29, 2024
0df4924
Apply review comments
lukasz-antoniak Oct 30, 2024
50324e8
Apply review comments
lukasz-antoniak Oct 31, 2024
7fbc872
Fix merge
lukasz-antoniak Apr 7, 2025
91a0251
Fix merge
lukasz-antoniak Apr 7, 2025
25ef9e8
More vector type tests
lukasz-antoniak Apr 8, 2025
396f52c
Apply review comments
lukasz-antoniak Apr 9, 2025
3c914d1
Apply review comments
lukasz-antoniak Apr 9, 2025
1d06cee
Apply review comments
lukasz-antoniak Apr 9, 2025
5c3e614
Apply review comments
lukasz-antoniak Apr 9, 2025
3750d00
Apply review comments
lukasz-antoniak Apr 10, 2025
e164af4
Test C* 5
lukasz-antoniak Apr 10, 2025
58e2a94
Move to Java 17
lukasz-antoniak Apr 10, 2025
ff5bc57
Revert "Move to Java 17"
lukasz-antoniak Apr 11, 2025
2219ea4
Test
lukasz-antoniak Apr 11, 2025
9eaebec
Test
lukasz-antoniak Apr 11, 2025
8b92ed4
Test
lukasz-antoniak Apr 11, 2025
2912cf5
Test
lukasz-antoniak Apr 11, 2025
9345765
Test
lukasz-antoniak Apr 11, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [ opened, synchronize, reopened ]

env:
CCM_VERSION: "6e71061146f7ae67b84ccd2b1d90d7319b640e4c"
CCM_VERSION: "4621dfee5ad73956b831091a8b863d100d25c610"

jobs:
build:
Expand All @@ -35,7 +35,7 @@ jobs:
fail-fast: false
matrix:
go: [ '1.22', '1.23' ]
cassandra_version: [ '4.0.13', '4.1.6' ]
cassandra_version: [ '4.0.13', '4.1.6', '5.0.3' ]
auth: [ "false" ]
compressor: [ "no-compression", "snappy", "lz4" ]
tags: [ "cassandra", "integration", "ccm" ]
Expand Down
57 changes: 30 additions & 27 deletions cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,15 @@ func TestCAS(t *testing.T) {
}

insertBatch := session.Batch(LoggedBatch)
insertBatch.Query("INSERT INTO cas_table (title, revid, last_modified) VALUES ('_foo', 2c3af400-73a4-11e5-9381-29463d90c3f0, DATEOF(NOW()))")
insertBatch.Query("INSERT INTO cas_table (title, revid, last_modified) VALUES ('_foo', 3e4ad2f1-73a4-11e5-9381-29463d90c3f0, DATEOF(NOW()))")
insertBatch.Query("INSERT INTO cas_table (title, revid, last_modified) VALUES ('_foo', 2c3af400-73a4-11e5-9381-29463d90c3f0, TOTIMESTAMP(NOW()))")
insertBatch.Query("INSERT INTO cas_table (title, revid, last_modified) VALUES ('_foo', 3e4ad2f1-73a4-11e5-9381-29463d90c3f0, TOTIMESTAMP(NOW()))")
if err := session.ExecuteBatch(insertBatch); err != nil {
t.Fatal("insert:", err)
}

failBatch = session.Batch(LoggedBatch)
failBatch.Query("UPDATE cas_table SET last_modified = DATEOF(NOW()) WHERE title='_foo' AND revid=2c3af400-73a4-11e5-9381-29463d90c3f0 IF last_modified=DATEOF(NOW());")
failBatch.Query("UPDATE cas_table SET last_modified = DATEOF(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified=DATEOF(NOW());")
failBatch.Query("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=2c3af400-73a4-11e5-9381-29463d90c3f0 IF last_modified=TOTIMESTAMP(NOW());")
failBatch.Query("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified=TOTIMESTAMP(NOW());")
if applied, iter, err := session.ExecuteBatchCAS(failBatch, &titleCAS, &revidCAS, &modifiedCAS); err != nil {
t.Fatal("insert:", err)
} else if applied {
Expand Down Expand Up @@ -533,21 +533,21 @@ func TestCAS(t *testing.T) {
}

failBatch = session.Batch(LoggedBatch)
failBatch.Query("UPDATE cas_table SET last_modified = DATEOF(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?", modified)
failBatch.Query("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?", modified)
if _, _, err := session.ExecuteBatchCAS(failBatch, new(bool)); err == nil {
t.Fatal("update should have errored")
}
// make sure MapScanCAS does not panic when MapScan fails
casMap = make(map[string]interface{})
casMap["last_modified"] = false
if _, err := session.Query(`UPDATE cas_table SET last_modified = DATEOF(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?`,
if _, err := session.Query(`UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?`,
modified).MapScanCAS(casMap); err == nil {
t.Fatal("update should hvae errored", err)
}

// make sure MapExecuteBatchCAS does not panic when MapScan fails
failBatch = session.Batch(LoggedBatch)
failBatch.Query("UPDATE cas_table SET last_modified = DATEOF(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?", modified)
failBatch.Query("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?", modified)
casMap = make(map[string]interface{})
casMap["last_modified"] = false
if _, _, err := session.MapExecuteBatchCAS(failBatch, casMap); err == nil {
Expand Down Expand Up @@ -2516,18 +2516,19 @@ func TestAggregateMetadata(t *testing.T) {
t.Fatal("expected two aggregates")
}

protoVer := byte(session.cfg.ProtoVersion)
expectedAggregrate := AggregateMetadata{
Keyspace: "gocql_test",
Name: "average",
ArgumentTypes: []TypeInfo{NativeType{typ: TypeInt}},
ArgumentTypes: []TypeInfo{NativeType{typ: TypeInt, proto: protoVer}},
InitCond: "(0, 0)",
ReturnType: NativeType{typ: TypeDouble},
ReturnType: NativeType{typ: TypeDouble, proto: protoVer},
StateType: TupleTypeInfo{
NativeType: NativeType{typ: TypeTuple},
NativeType: NativeType{typ: TypeTuple, proto: protoVer},

Elems: []TypeInfo{
NativeType{typ: TypeInt},
NativeType{typ: TypeBigInt},
NativeType{typ: TypeInt, proto: protoVer},
NativeType{typ: TypeBigInt, proto: protoVer},
},
},
stateFunc: "avgstate",
Expand Down Expand Up @@ -2566,28 +2567,29 @@ func TestFunctionMetadata(t *testing.T) {
avgState := functions[1]
avgFinal := functions[0]

protoVer := byte(session.cfg.ProtoVersion)
avgStateBody := "if (val !=null) {state.setInt(0, state.getInt(0)+1); state.setLong(1, state.getLong(1)+val.intValue());}return state;"
expectedAvgState := FunctionMetadata{
Keyspace: "gocql_test",
Name: "avgstate",
ArgumentTypes: []TypeInfo{
TupleTypeInfo{
NativeType: NativeType{typ: TypeTuple},
NativeType: NativeType{typ: TypeTuple, proto: protoVer},

Elems: []TypeInfo{
NativeType{typ: TypeInt},
NativeType{typ: TypeBigInt},
NativeType{typ: TypeInt, proto: protoVer},
NativeType{typ: TypeBigInt, proto: protoVer},
},
},
NativeType{typ: TypeInt},
NativeType{typ: TypeInt, proto: protoVer},
},
ArgumentNames: []string{"state", "val"},
ReturnType: TupleTypeInfo{
NativeType: NativeType{typ: TypeTuple},
NativeType: NativeType{typ: TypeTuple, proto: protoVer},

Elems: []TypeInfo{
NativeType{typ: TypeInt},
NativeType{typ: TypeBigInt},
NativeType{typ: TypeInt, proto: protoVer},
NativeType{typ: TypeBigInt, proto: protoVer},
},
},
CalledOnNullInput: true,
Expand All @@ -2604,16 +2606,16 @@ func TestFunctionMetadata(t *testing.T) {
Name: "avgfinal",
ArgumentTypes: []TypeInfo{
TupleTypeInfo{
NativeType: NativeType{typ: TypeTuple},
NativeType: NativeType{typ: TypeTuple, proto: protoVer},

Elems: []TypeInfo{
NativeType{typ: TypeInt},
NativeType{typ: TypeBigInt},
NativeType{typ: TypeInt, proto: protoVer},
NativeType{typ: TypeBigInt, proto: protoVer},
},
},
},
ArgumentNames: []string{"state"},
ReturnType: NativeType{typ: TypeDouble},
ReturnType: NativeType{typ: TypeDouble, proto: protoVer},
CalledOnNullInput: true,
Language: "java",
Body: finalStateBody,
Expand Down Expand Up @@ -2717,15 +2719,16 @@ func TestKeyspaceMetadata(t *testing.T) {
if flagCassVersion.Before(3, 0, 0) {
textType = TypeVarchar
}
protoVer := byte(session.cfg.ProtoVersion)
expectedType := UserTypeMetadata{
Keyspace: "gocql_test",
Name: "basicview",
FieldNames: []string{"birthday", "nationality", "weight", "height"},
FieldTypes: []TypeInfo{
NativeType{typ: TypeTimestamp},
NativeType{typ: textType},
NativeType{typ: textType},
NativeType{typ: textType},
NativeType{typ: TypeTimestamp, proto: protoVer},
NativeType{typ: textType, proto: protoVer},
NativeType{typ: textType, proto: protoVer},
NativeType{typ: textType, proto: protoVer},
},
}
if !reflect.DeepEqual(*keyspaceMetadata.UserTypes["basicview"], expectedType) {
Expand Down
13 changes: 13 additions & 0 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"flag"
"fmt"
"log"
"math/rand"
"net"
"reflect"
"strings"
Expand All @@ -54,6 +55,10 @@ var (
flagCassVersion cassVersion
)

var seededRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))

const randCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

func init() {
flag.Var(&flagCassVersion, "gocql.cversion", "the cassandra version being tested against")

Expand Down Expand Up @@ -281,6 +286,14 @@ func assertTrue(t *testing.T, description string, value bool) {
}
}

func randomText(size int) string {
result := make([]byte, size)
for i := range result {
result[i] = randCharset[rand.Intn(len(randCharset))]
}
return string(result)
}

func assertEqual(t *testing.T, description string, expected, actual interface{}) {
t.Helper()
if expected != actual {
Expand Down
17 changes: 17 additions & 0 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"io/ioutil"
"net"
"runtime"
"strconv"
"strings"
"time"
)
Expand Down Expand Up @@ -905,6 +906,22 @@ func (f *framer) readTypeInfo() TypeInfo {
collection.Elem = f.readTypeInfo()

return collection
case TypeCustom:
if strings.HasPrefix(simple.custom, VECTOR_TYPE) {
spec := strings.TrimPrefix(simple.custom, VECTOR_TYPE)
spec = spec[1 : len(spec)-1] // remove parenthesis
idx := strings.LastIndex(spec, ",")
typeStr := spec[:idx]
dimStr := spec[idx+1:]
subType := getCassandraLongType(strings.TrimSpace(typeStr), f.proto, nopLogger{})
dim, _ := strconv.Atoi(strings.TrimSpace(dimStr))
vector := VectorType{
NativeType: simple,
SubType: subType,
Dimensions: dim,
}
return vector
}
}

return simple
Expand Down
Loading