Re: insert into ... select statement

2019-04-22 Thread cclive1601你
you can use cassandra trigger

xiaobo  于2019年4月23日周二 下午1:23写道:

> Hi,
>
> Can we use the result from a select statement to insert into another table
> directlly like other RDBMS in cassandra?
>
> Thanks.
>


-- 
you are the apple of my eye !


insert into ... select statement

2019-04-22 Thread xiaobo
Hi,


Can we use the result from a select statement to insert into another table 
directlly like other RDBMS in cassandra?


Thanks.

Re: Cassandra upsert ordering issue for list type fields

2019-04-22 Thread Naman Gupta
Hi shaurya,

Thanks for the response! I am using cassandra 3.11.4, but I have observed
the same nature on Cassandra 3.0.15 as well. I think by cqlsh command you
mean the updare statements. I gather the update statements mentioned by me
were rather rudimentary (for explanation purposes) but for that sake they
would look like..

UPDATE "" USING TTL 31536000 SET "firstname"="firstname"+?,
"lastname"="lastname" + ? with params: ["leonardo","dicaprio"]

UPDATE "" USING TTL 31536000 SET "firstname"="firstname"+?,
"lastname"="lastname" + ? with params: ["brad","pitt"]

and so on...

you can also refer to my original post on reddit,
https://www.reddit.com/r/cassandra/comments/be5vac/cassandra_update_add_ordering_issue/
For an even more informative discussion around the same.

Will appreciate any help here from the cassadnra community :)

Thanks,
Naman

On Mon, Apr 22, 2019 at 9:29 PM Shaurya Gupta 
wrote:

> Which version of Cassandra are you using?
> https://docs.datastax.com/en/cql/3.3/cql/cql_using/useInsertList.html and
> many other relevant pages do not mention any thing of the CQLSH command
> mentioned by you above.
>
> --
> Shaurya
>
> On Mon, Apr 22, 2019 at 6:51 PM Naman Gupta 
> wrote:
>
>> I am facing issue with cassandra ordering in the tables for column types
>> of list.
>>
>> Suppose I have a table as follows...
>> FirstName:  of string
>> LastName:   of string
>>
>> now if were to Issue
>> update  (FirstName,LastName) add values ("Leonardo","DiCaprio")
>> update  (FirstName,LastName) add values ("Brad","Pitt")
>> update  (FirstName,LastName) add values ("mathhew","mcconehey")
>> update  (FirstName,LastName) add values ("Kate","Beckinsale")
>> update  (FirstName,LastName) add values ("Eva","Green")
>>
>>
>> If I use the upserts with some time gap in between I get expected results
>> i.e
>>
>> cqlsh output:->
>> Firsname: Leonardo | Brad | Matthew  | Kate| Eva
>> LastName: DiCaprio | Pitt | Mcconahey | Beckinsale | Green
>>
>>
>> But If I updsert in a quick burst (Imagine in a for loop), I get
>> unexpected results
>>
>> cqlsh
>> Firstname: Leonardo | brad| Matthew  | Kate| Eva
>> Lastname:  pitt| dicaprio  | Mcconahey | Beckinsale | Green
>>
>> As you can see above, generally two or so values in a column (here
>> lastname) are interchanged. When the data is more, the tendency of
>> unordering increases than 5 upsert queries
>>
>> When I flushed the db tables and took a ssTable dump using sstabledump
>> , I observed that the ordering reflected in the cqlsh output
>> is exactly the way it is written in the sstable. Which means that in the
>> example 2 above, for column "firstname" leonardo was written before brad
>> and for column "lastname" pitt was written before dicarpio.
>>
>> Now I am confused as to why writes which should be one one at a time are
>> seemed to be written in an unordered fashion across columns. Please note
>> that a write where the whole pair (firstname,lastname) TOGETHER changes
>> it's position is still acceptable i.e.
>>
>> cqlsh
>> Firstname: brad | leonardo| Matthew  | Kate| Eva
>> Lastname:  pitt| dicaprio  | Mcconahey | Beckinsale | Green
>>
>> ... would have been completely acceptable provided the fact I will
>> retrieve them by using the indedx [0] would mean brad pitt and [1] would
>> mean leonardo dicaprio in my applications
>> But the same indexed based retrieval would fail in case 2 where [0] would
>> mean leonardo pitt and [1] would mean brad dicaprio.
>>
>> Please help with any insights, I would be really grateful.
>>
>
>
> --
> Shaurya Gupta
>
>
>


Can we set the precision of decimal column

2019-04-22 Thread xiaobo
Hi,


We usually use decaimal data type for money, can we set decimal columns with a 
specific precision?


Thanks.

Re: Unpair cassandra datacenters

2019-04-22 Thread Sandeep Nethi
Hi Kunal,

The simple solution for this case would be as follows,

1. Run *Full repair.*
2. Add firewall to block network on port 7000(,7001 if ssl enabled) between
two datacenter nodes.
3. Check the status of cassandra cluster from both data centers, each DC
must show down node status of another DC nodes after the firewall change.
4. Change replication factor for all keyspaces on each data center.
5. Start decommissioning nodes from each datacenter (Should be removenode
in this case).
6. Update seeds list on each datacenter to local datacenter nodes and
perform a rolling restart.

Hope this helps, Try to test this scenario on non-prod system first.

Thanks,
Sandeep

On Tue, Apr 23, 2019 at 11:00 AM Kunal  wrote:

> HI Marc,
>
> Appreciate your prompt response.
>
> Yes we are starting datacenter B from scratch. We tried using cluster name
> change on side B and it works but our requirement says we can not change
> cluster name because during our product's major or patch release, the
> scripts expect cluster name to be the same.
> .
> On datacenter B , we are changing the seeds nodes. On datacenter A , we
> are changing the seeds nodes in cassandra.yml but that will be picked up
> during cassandra restart only but we can not have downtime for datacenter
> A. It has to be up all the time.
>
>
> Regards,
> Kunal Vaid
>
>
> On Mon, Apr 22, 2019 at 3:49 PM Marc Selwan 
> wrote:
>
>> Hi Kunal,
>>
>> Did you edit the cassandra.yaml file in each data center to remove the
>> seed nodes? On which ever data center is starting from scratch (I think
>> it's B in your case), you may want to also change the cluster name.
>>
>> Best,
>> *Marc Selwan | *DataStax *| *PM, Server Team *|* *(925) 413-7079* *|*
>> Twitter 
>>
>> *  Quick links | *DataStax  *| *Training
>>  *| *Documentation
>> 
>>  *| *Downloads 
>>
>>
>>
>> On Mon, Apr 22, 2019 at 3:38 PM Kunal  wrote:
>>
>>> Hi Friends,
>>>
>>> I need small help in unpairing two datacenters.
>>> We have 2 datacenters (say A and B ) with 3 nodes in each datacenter. We
>>> want to remove one whole data center (B) (3 nodes) from the other one (B).
>>> basically, want to unpair both datacenter and want to use them both
>>> individually.
>>> We are trying this using nodetool decommission and it is removing the 3
>>> nodes from B datacenter. But when we are trying to bring up datacenter B to
>>> use it separately from Datacenter A, it is joining back to datacenter A. We
>>> noticed in debug.log, nodes from datacenter A keeps looking for nodes in
>>> datacenter B and getting connection refused error when the nodes of
>>> datacenter B are down, but as soon as nodes comes back, they are joining to
>>> the cluster.
>>> We don't want nodes from datacenter B to join datacenter A once they are
>>> decommissioned.
>>>
>>> Can you please let me know if i am missing anything.
>>>
>>> Thanks in advance.
>>>
>>> Regards,
>>> Kunal Vaid
>>>
>>
>
> --
>
>
>
> Regards,
> Kunal Vaid
>


Re: Unpair cassandra datacenters

2019-04-22 Thread Kunal
HI Marc,

Appreciate your prompt response.

Yes we are starting datacenter B from scratch. We tried using cluster name
change on side B and it works but our requirement says we can not change
cluster name because during our product's major or patch release, the
scripts expect cluster name to be the same.
.
On datacenter B , we are changing the seeds nodes. On datacenter A , we are
changing the seeds nodes in cassandra.yml but that will be picked up during
cassandra restart only but we can not have downtime for datacenter A. It
has to be up all the time.


Regards,
Kunal Vaid


On Mon, Apr 22, 2019 at 3:49 PM Marc Selwan 
wrote:

> Hi Kunal,
>
> Did you edit the cassandra.yaml file in each data center to remove the
> seed nodes? On which ever data center is starting from scratch (I think
> it's B in your case), you may want to also change the cluster name.
>
> Best,
> *Marc Selwan | *DataStax *| *PM, Server Team *|* *(925) 413-7079* *|*
> Twitter 
>
> *  Quick links | *DataStax  *| *Training
>  *| *Documentation
> 
>  *| *Downloads 
>
>
>
> On Mon, Apr 22, 2019 at 3:38 PM Kunal  wrote:
>
>> Hi Friends,
>>
>> I need small help in unpairing two datacenters.
>> We have 2 datacenters (say A and B ) with 3 nodes in each datacenter. We
>> want to remove one whole data center (B) (3 nodes) from the other one (B).
>> basically, want to unpair both datacenter and want to use them both
>> individually.
>> We are trying this using nodetool decommission and it is removing the 3
>> nodes from B datacenter. But when we are trying to bring up datacenter B to
>> use it separately from Datacenter A, it is joining back to datacenter A. We
>> noticed in debug.log, nodes from datacenter A keeps looking for nodes in
>> datacenter B and getting connection refused error when the nodes of
>> datacenter B are down, but as soon as nodes comes back, they are joining to
>> the cluster.
>> We don't want nodes from datacenter B to join datacenter A once they are
>> decommissioned.
>>
>> Can you please let me know if i am missing anything.
>>
>> Thanks in advance.
>>
>> Regards,
>> Kunal Vaid
>>
>

-- 



Regards,
Kunal Vaid


Re: Unpair cassandra datacenters

2019-04-22 Thread Marc Selwan
Hi Kunal,

Did you edit the cassandra.yaml file in each data center to remove the seed
nodes? On which ever data center is starting from scratch (I think it's B
in your case), you may want to also change the cluster name.

Best,
*Marc Selwan | *DataStax *| *PM, Server Team *|* *(925) 413-7079* *|*
Twitter 

*  Quick links | *DataStax  *| *Training
 *| *Documentation

 *| *Downloads 



On Mon, Apr 22, 2019 at 3:38 PM Kunal  wrote:

> Hi Friends,
>
> I need small help in unpairing two datacenters.
> We have 2 datacenters (say A and B ) with 3 nodes in each datacenter. We
> want to remove one whole data center (B) (3 nodes) from the other one (B).
> basically, want to unpair both datacenter and want to use them both
> individually.
> We are trying this using nodetool decommission and it is removing the 3
> nodes from B datacenter. But when we are trying to bring up datacenter B to
> use it separately from Datacenter A, it is joining back to datacenter A. We
> noticed in debug.log, nodes from datacenter A keeps looking for nodes in
> datacenter B and getting connection refused error when the nodes of
> datacenter B are down, but as soon as nodes comes back, they are joining to
> the cluster.
> We don't want nodes from datacenter B to join datacenter A once they are
> decommissioned.
>
> Can you please let me know if i am missing anything.
>
> Thanks in advance.
>
> Regards,
> Kunal Vaid
>


Unpair cassandra datacenters

2019-04-22 Thread Kunal
Hi Friends,

I need small help in unpairing two datacenters.
We have 2 datacenters (say A and B ) with 3 nodes in each datacenter. We
want to remove one whole data center (B) (3 nodes) from the other one (B).
basically, want to unpair both datacenter and want to use them both
individually.
We are trying this using nodetool decommission and it is removing the 3
nodes from B datacenter. But when we are trying to bring up datacenter B to
use it separately from Datacenter A, it is joining back to datacenter A. We
noticed in debug.log, nodes from datacenter A keeps looking for nodes in
datacenter B and getting connection refused error when the nodes of
datacenter B are down, but as soon as nodes comes back, they are joining to
the cluster.
We don't want nodes from datacenter B to join datacenter A once they are
decommissioned.

Can you please let me know if i am missing anything.

Thanks in advance.

Regards,
Kunal Vaid


Re: Cassandra upsert ordering issue for list type fields

2019-04-22 Thread Shaurya Gupta
Which version of Cassandra are you using?
https://docs.datastax.com/en/cql/3.3/cql/cql_using/useInsertList.html and
many other relevant pages do not mention any thing of the CQLSH command
mentioned by you above.

--
Shaurya

On Mon, Apr 22, 2019 at 6:51 PM Naman Gupta 
wrote:

> I am facing issue with cassandra ordering in the tables for column types
> of list.
>
> Suppose I have a table as follows...
> FirstName:  of string
> LastName:   of string
>
> now if were to Issue
> update  (FirstName,LastName) add values ("Leonardo","DiCaprio")
> update  (FirstName,LastName) add values ("Brad","Pitt")
> update  (FirstName,LastName) add values ("mathhew","mcconehey")
> update  (FirstName,LastName) add values ("Kate","Beckinsale")
> update  (FirstName,LastName) add values ("Eva","Green")
>
>
> If I use the upserts with some time gap in between I get expected results
> i.e
>
> cqlsh output:->
> Firsname: Leonardo | Brad | Matthew  | Kate| Eva
> LastName: DiCaprio | Pitt | Mcconahey | Beckinsale | Green
>
>
> But If I updsert in a quick burst (Imagine in a for loop), I get
> unexpected results
>
> cqlsh
> Firstname: Leonardo | brad| Matthew  | Kate| Eva
> Lastname:  pitt| dicaprio  | Mcconahey | Beckinsale | Green
>
> As you can see above, generally two or so values in a column (here
> lastname) are interchanged. When the data is more, the tendency of
> unordering increases than 5 upsert queries
>
> When I flushed the db tables and took a ssTable dump using sstabledump
> , I observed that the ordering reflected in the cqlsh output
> is exactly the way it is written in the sstable. Which means that in the
> example 2 above, for column "firstname" leonardo was written before brad
> and for column "lastname" pitt was written before dicarpio.
>
> Now I am confused as to why writes which should be one one at a time are
> seemed to be written in an unordered fashion across columns. Please note
> that a write where the whole pair (firstname,lastname) TOGETHER changes
> it's position is still acceptable i.e.
>
> cqlsh
> Firstname: brad | leonardo| Matthew  | Kate| Eva
> Lastname:  pitt| dicaprio  | Mcconahey | Beckinsale | Green
>
> ... would have been completely acceptable provided the fact I will
> retrieve them by using the indedx [0] would mean brad pitt and [1] would
> mean leonardo dicaprio in my applications
> But the same indexed based retrieval would fail in case 2 where [0] would
> mean leonardo pitt and [1] would mean brad dicaprio.
>
> Please help with any insights, I would be really grateful.
>


-- 
Shaurya Gupta


Cassandra upsert ordering issue for list type fields

2019-04-22 Thread Naman Gupta
I am facing issue with cassandra ordering in the tables for column types of
list.

Suppose I have a table as follows...
FirstName:  of string
LastName:   of string

now if were to Issue
update  (FirstName,LastName) add values ("Leonardo","DiCaprio")
update  (FirstName,LastName) add values ("Brad","Pitt")
update  (FirstName,LastName) add values ("mathhew","mcconehey")
update  (FirstName,LastName) add values ("Kate","Beckinsale")
update  (FirstName,LastName) add values ("Eva","Green")


If I use the upserts with some time gap in between I get expected results
i.e

cqlsh output:->
Firsname: Leonardo | Brad | Matthew  | Kate| Eva
LastName: DiCaprio | Pitt | Mcconahey | Beckinsale | Green


But If I updsert in a quick burst (Imagine in a for loop), I get unexpected
results

cqlsh
Firstname: Leonardo | brad| Matthew  | Kate| Eva
Lastname:  pitt| dicaprio  | Mcconahey | Beckinsale | Green

As you can see above, generally two or so values in a column (here
lastname) are interchanged. When the data is more, the tendency of
unordering increases than 5 upsert queries

When I flushed the db tables and took a ssTable dump using sstabledump
, I observed that the ordering reflected in the cqlsh output
is exactly the way it is written in the sstable. Which means that in the
example 2 above, for column "firstname" leonardo was written before brad
and for column "lastname" pitt was written before dicarpio.

Now I am confused as to why writes which should be one one at a time are
seemed to be written in an unordered fashion across columns. Please note
that a write where the whole pair (firstname,lastname) TOGETHER changes
it's position is still acceptable i.e.

cqlsh
Firstname: brad | leonardo| Matthew  | Kate| Eva
Lastname:  pitt| dicaprio  | Mcconahey | Beckinsale | Green

... would have been completely acceptable provided the fact I will retrieve
them by using the indedx [0] would mean brad pitt and [1] would mean
leonardo dicaprio in my applications
But the same indexed based retrieval would fail in case 2 where [0] would
mean leonardo pitt and [1] would mean brad dicaprio.

Please help with any insights, I would be really grateful.