apache / apache/cassandra-gocql-driver

Bug with tuple

Open
#1,909 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.7k
Forks
658
PR merge metrics
No merged PRs in 30d

Description

I'm running this:

```go
func (i *snapshotIterator) Next() ([]map[string]any, error) {
if i.done {
return nil, fmt.Errorf("no more rows to scan")
}

if i.iter == nil {
colNames := make([]string, len(i.columns))
for idx, col := range i.columns {
// Cassandra identifiers are typically lowercase; avoid quoting to keep it simple.
colNames[idx] = col.Name
}

// Build fully-qualified table name keyspace.table
stmt := fmt.Sprintf("SELECT %s FROM %s.%s", strings.Join(colNames, ","), i.keyspace, i.tableName)
fmt.Println("stmt", stmt)
i.iter = i.session.Query(stmt).PageSize(i.batchSize).Iter()
}

var rows []map[string]any
for len(rows) < i.batchSize {
row := make(map[string]any)
if !i.iter.MapScan(row) {
i.done = true
break
}

out, err := i.normalizeRow(row)
if err != nil {
return nil, fmt.Errorf("failed to normalize row: %w", err)
}

rows = append(rows, out)
}

return rows, nil
}
```

You can clearly see that `c_tuple_int_text` is null:

Image

However, this is what I'm getting back:

```go
stmt SELECT id,c_ascii,c_bigint,c_blob,c_boolean,c_date,c_decimal,c_double,c_float,c_frozen_list_int,c_inet,c_int,c_smallint,c_text,c_time,c_timestamp,c_timeuuid,c_tinyint,c_tuple_int_text,c_uuid,c_varchar,c_varint,c_list_int,c_map_text_int,c_set_int FROM artie_test.data_type_test
key c_double value 4.14159
key c_time value 12h34m56s
key c_timestamp value 2025-09-10 23:45:22.811 +0000 UTC
key c_tinyint value 42
key c_varint value 1234567890123456789
key c_timeuuid value 37a76f2c-8ea0-11f0-bed0-d6c22f62521e
key c_list_int value [10]
key c_map_text_int value map[a:1 b:2]
key c_set_int value [1]
key c_ascii value ascii_1
key c_boolean value false
key c_decimal value 123.45
key c_float value 3.71828
key c_tuple_int_text[0] value 0
key c_tuple_int_text[1] value
key c_varchar value varchar_1
key id value 2
key c_blob value [1 2 3 1]
key c_frozen_list_int value [1]
key c_inet value 10.0.1.2
key c_int value 1001
key c_smallint value 1234
key c_text value text_1
key c_uuid value baed9c37-e600-497d-857d-852d395dad07
key c_bigint value 9000000001
key c_date value 2025-09-10 00:00:00 +0000 UTC
```

Contributor guide

Open the contributing guide

Research direction

Start at snapshotIterator.Next and inspect normalizeRow, since the report shows the tuple value changing during row normalization but names no source file or test. Trace how MapScan represents a null c_tuple_int_text value and verify that normalization preserves null rather than producing zero values; done means the returned row matches the Cassandra value.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.