Dynamic schema changes are generally a bad idea, especially if they are rapid.
You should rethink your approach. On Fri, Nov 13, 2015 at 7:20 AM, Rajesh Radhakrishnan < rajesh.radhakrish...@phe.gov.uk> wrote: > > Thank you Carlos for looking. > But when I rand the nodetool describecluster. > It is showing the same schema versions for both nodes? > > So it is something else! Please help me from this bottleneck. Thank you. > > ------------------------------ > *From:* Carlos Alonso [i...@mrcalonso.com] > *Sent:* 13 November 2015 11:55 > *To:* user@cassandra.apache.org > *Subject:* Re: Getting code=2200 [Invalid query] message=Invalid column > name ... while executing ALTER statement > > Maybe schema disagreement? > > Run nodetool describecluster to discover > > Carlos Alonso | Software Engineer | @calonso <https://twitter.com/calonso> > > On 13 November 2015 at 11:14, Rajesh Radhakrishnan < > rajesh.radhakrish...@phe.gov.uk> wrote: > >> >> Hi, >> >> I am using Cassandra 2.1.5 in a cluster of two nodes (running CentOS) and >> using Python driver to connect to Cassandra. >> My Python code snippet is show here: >> >> >> #------------------------------------------------------------------------------------------------------------------- >> import time, os, datetime, keyword >> import uuid >> from cassandra.cluster import Cluster >> import os.path, sys >> .... >> from cassandra.auth import PlainTextAuthProvider >> .... >> auth_provider = PlainTextAuthProvider(username, password) >> cluster = Cluster([node1,node2],auth_provider=auth_provider) >> session = cluster.connect(); >> >> session.execute("CREATE table IF NOT EXISTS test.iau (" >> "id uuid, " >> "sample_id text, " >> "PRIMARY KEY (sample_id) )"); >> >> print " \n created the table" >> #-------- >> >> sqlInsertSampleIdUid = "INSERT INTO test.iau (id, sample_id) >> VALUES ("+str(uuid.uuid1())+",'sample123')" >> session.execute(sqlInsertSampleIdUid) >> print " \n Inserted main ids into the table" >> #------- >> >> colNames >> =['col1','col2','col3','col4','col5','col6','col7','col8','col9'] >> >> for colName in colNames : >> >> sqlAlterStatement1 = " ALTER TABLE test.iau ADD "+colName+" >> text" >> print sqlAlterStatement1 >> session.execute(sqlAlterStatement1) >> sqlAlterStatement1 = None >> >> print " Altered tables :: " >> # ---------------------------------------- >> count = 0 >> for colName in colNames : >> count = count +1 >> sqlUpdateGeneDetection = " UPDATE test.iau SET "+colName+" = >> '"+str(count)+"' WHERE sample_id = 'sample123'" >> session.execute(sqlUpdateGeneDetection) >> sqlUpdateGeneDetection = None >> >> print " Updated tables :: " >> session.cluster.shutdown() >> .... >> >> #------------------------------------------------------------------------------------------------------------------- >> >> Very rarely this code works, but most of the time it fails when it reach >> ALTER statement. >> FYI, I tried preparedstatement with binding in INSERT, UPDATE statements >> too. >> >> The error with output is shown here: >> >> #------ >> created the table >> >> Inserted main ids into the table >> ALTER TABLE test.iau ADD col1 text >> ALTER TABLE test.iau ADD col2 text >> ALTER TABLE test.iau ADD col3 text >> ALTER TABLE test.iau ADD col4 text >> ALTER TABLE test.iau ADD col5 text >> ALTER TABLE test.iau ADD col6 text >> ALTER TABLE test.iau ADD col7 text >> ALTER TABLE test.iau ADD col8 text >> ALTER TABLE test.iau ADD col9 text >> E >> ====================================================================== >> >> ---------------------------------------------------------------------- >> Traceback (most recent call last): >> File "UnitTests.py", line 313, in test_insert_data >> session.execute(sqlAlterStatement1) >> File "/usr/local/lib/python2.7/site-packages/cassandra/cluster.py", >> line 1405, in execute >> result = future.result(timeout) >> File "/usr/local/lib/python2.7/site-packages/cassandra/cluster.py", >> line 2976, in result >> raise self._final_exception >> InvalidRequest: code=2200 [Invalid query] message="Invalid column name >> col9 because it conflicts with an existing column" >> >> ---------------------------------------------------------------------- >> Ran 1 test in 9.856s >> #------ >> >> But when I checked the table using CQL col9 is not there. >> >> Is there' schema' refresh issue or is it bug in Cassandra 2.1.5? >> >> Thank you. >> Kind regards >> Rajesh R >> >> >> >> ************************************************************************** >> The information contained in the EMail and any attachments is >> confidential and intended solely and for the attention and use of the named >> addressee(s). It may not be disclosed to any other person without the >> express authority of Public Health England, or the intended recipient, or >> both. If you are not the intended recipient, you must not disclose, copy, >> distribute or retain this message or any part of it. This footnote also >> confirms that this EMail has been swept for computer viruses by >> Symantec.Cloud, but please re-sweep any attachments before opening or >> saving. http://www.gov.uk/PHE >> ************************************************************************** >> > > > ************************************************************************** > The information contained in the EMail and any attachments is confidential > and intended solely and for the attention and use of the named > addressee(s). It may not be disclosed to any other person without the > express authority of Public Health England, or the intended recipient, or > both. If you are not the intended recipient, you must not disclose, copy, > distribute or retain this message or any part of it. This footnote also > confirms that this EMail has been swept for computer viruses by > Symantec.Cloud, but please re-sweep any attachments before opening or > saving. http://www.gov.uk/PHE > ************************************************************************** >