Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WriteOptions not allowing using timestamp #21

Closed
hemabs opened this issue Sep 3, 2014 · 7 comments
Closed

WriteOptions not allowing using timestamp #21

hemabs opened this issue Sep 3, 2014 · 7 comments

Comments

@hemabs
Copy link

hemabs commented Sep 3, 2014

I am currently working on setting up the using options for an insert statement using WriteOptions/QueryOptions class. To my surprise, prior to this set and get methods for timestamp were allowed in WriteOptions. May I know why has this been deleted and how can i use the below feature:

insert into table(.....) values(.....) using timestamp 1240003134;

@matthewadams
Copy link
Contributor

Can you please be more specific? Where are you attempting to set using options for an insert statement?

@hemabs
Copy link
Author

hemabs commented Sep 3, 2014

I want to set timestamp in below code:
WriteOptions options = new WriteOptions();
options.setTtl(60);
options.setConsistencyLevel(ConsistencyLevel.ONE);
options.setRetryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY);

then use the execute(cql, queryWriteOptions); which accepts WriteOptions/QueryOptions as parameter.

@hemabs
Copy link
Author

hemabs commented Sep 3, 2014

I see TTL here;

But the insert syntax accepts TIMESTAMP as below:

::= INSERT INTO
'(' ( ',' )* ')'
VALUES '(' ( ',' )* ')'
( IF NOT EXISTS )?
( USING ( AND )* )?

::=
|

::= TIMESTAMP | TTL

@hemabs
Copy link
Author

hemabs commented Sep 3, 2014

Here is the link to the syntax:
https://cassandra.apache.org/doc/cql3/CQL.html#selectStmt

@matthewadams
Copy link
Contributor

Ah, I see. You've caught us midstream on a change where we're deprecating the method execute(String,QueryOptions). I haven't merged the code back in to master from branch DATACASS-145, but the problem is that there is a limitation in the underlying C* Java driver. We have no way of knowing what kind of statement is being given in the string, so we must use the driver's SimpleStatement class; see the code here. Unfortunately, SimpleStatement, which indirectly extends Statement, does not support setting the TTL. The new deprecation warning, if you want to see it, is here.

If you want to set TTL for an INSERT or UPDATE statement, you must either embed the USING clause into the given CQL string that you pass to execute(String,QueryOptions), or use one of either execute(Insert) or execute(Update) and use Insert or Update's support for TTL. If there were a way to construct an Insert or Update object via an arbitrary string, we might be able to once again support the method (albeit in another form), but the driver gives us no such capability.

I'm closing this issue, since we're at the underlying C* Java driver's mercy here. Sorry.

@matthewadams
Copy link
Contributor

Incidentally, I'm not sure that WriteOptions ever supported a timestamp property. I've noted that we should add support for it in https://jira.spring.io/browse/DATACASS-155, though.

@hemabs
Copy link
Author

hemabs commented Sep 3, 2014

Thanks for the input Matthew. Its very helpful. Also thanking you for adding future support with timestamp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants