Git Product home page Git Product logo

Comments (7)

matthewadams avatar matthewadams commented on April 26, 2024

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

from spring-data-cassandra.

hemabs avatar hemabs commented on April 26, 2024

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.

from spring-data-cassandra.

hemabs avatar hemabs commented on April 26, 2024

I see TTL here;

But the insert syntax accepts TIMESTAMP as below:

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

::=
|

::= TIMESTAMP | TTL

from spring-data-cassandra.

hemabs avatar hemabs commented on April 26, 2024

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

from spring-data-cassandra.

matthewadams avatar matthewadams commented on April 26, 2024

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.

from spring-data-cassandra.

matthewadams avatar matthewadams commented on April 26, 2024

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.

from spring-data-cassandra.

hemabs avatar hemabs commented on April 26, 2024

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

from spring-data-cassandra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.