Add TIMESTAMP data type to Cassandra Plugin

Description

Using the following CQL:
create table if not exists ks.people (
id int primary key,
name text,
birth_date timestamp
);

insert into ks.people (id, name, birth_date) values (10, 'Catherine', '1987-12-02');
insert into ks.people (id, name, birth_date) values (11, 'Isadora', '2004-09-08');
insert into ks.people (id, name, birth_date) values (12, 'Anna', '1970-10-02');

When reading this table from ECL, the timestamps are left unbound. They can be read as data elements like so:

person := RECORD
integer4 id,
string name,
data birth_date
END;

But using other data types results in:

<Exception><Source>Roxie</Source><Message>cassandra: type mismatch - integer expected for field birth_date, received TIMESTAMP</Message></Exception>

We should add the ability to bind TIMESTAMP typed elements in the Cassandra plugin. I'll have a look at doing this.

Conclusion

None

Activity

Show:

Brian O'Neill May 5, 2015 at 4:09 AM

Brian O'Neill May 5, 2015 at 3:52 AM

In the cpp-driver, it looks like TIMESTAMP is treated as an int64:

From values.cpp,
CassError cass_value_get_int64(const CassValue* value, cass_int64_t* output) {
...
if (value->type() != CASS_VALUE_TYPE_TIMESTAMP)
return CASS_ERROR_LIB_INVALID_VALUE_TYPE;
...
}

I've added TIMESTAMP to the case statements, and it is now returning, but with an incorrect value.

Brian O'Neill May 5, 2015 at 1:39 AM

Interesting, it looks like there might be multiple aspects to this:
1) The ability to use timetamps as parameters (which requires binding)
2) The ability to get timestamps back from Cassandra (which appears to require a column mapper)

Looking at this code:

class TimeStampColumnMapper : implements CassandraColumnMapper
{
public:
virtual IPTree *toXML(IPTree *row, const char *name, const CassValue *value)
{
// never fetched (that may change?)
return row;
}
virtual void fromXML(CassStatement *statement, unsigned idx, IPTree *row, const char *name, int userVal)
{
// never bound
}
} timestampColumnMapper;

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Priority

Fix versions

Pull Request URL

Created May 5, 2015 at 1:30 AM
Updated May 6, 2015 at 2:12 PM
Resolved May 6, 2015 at 2:11 PM