cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kuku1 (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CASSANDRA-12450) CQLSSTableWriter does not allow Update statement
Date Fri, 12 Aug 2016 14:07:20 GMT

     [ https://issues.apache.org/jira/browse/CASSANDRA-12450?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kuku1 updated CASSANDRA-12450:
------------------------------
    Description: 
CQLSSTableWriter throws Exception when trying to use Update statement.
Has been working fine in previous versions for me.

Code:
{code}
	public static void main(String[] args) throws IOException {
		final String KS = "test";
		final String TABLE = "data";

		final String schema = "CREATE TABLE " + KS + "." + TABLE
				+ "(k text, c1 text, c2 text, c3 text, v text, primary key(k, c1,c2,c3))";

		final String query = "UPDATE " + KS + "." + TABLE + " SET v = ? WHERE k = ? and c1 = ? and
c2 = ?";

		File dataDir = new File(...);

		CQLSSTableWriter writer = CQLSSTableWriter.builder().inDirectory(dataDir).forTable(schema).using(query).build();
//Exception here (see below) 

		HashMap<String, Object> row = new HashMap<>();

		row.put("k", "a");
		row.put("c1", "a");
		row.put("c2", "a");
		row.put("c3", "a");
		row.put("v", "v");

		writer.addRow(row);
		writer.close();

	}

{code}

Exception:
{code}
14:51:00.461 [main] INFO  o.a.cassandra.cql3.QueryProcessor - Initialized prepar
ed statement caches with 0 MB (native) and 0 MB (Thrift)
Exception in thread "main" java.lang.IllegalArgumentException: Invalid query, mu
st be a INSERT statement but was: class org.apache.cassandra.cql3.statements.Upd
ateStatement$ParsedUpdate
        at org.apache.cassandra.io.sstable.CQLSSTableWriter.parseStatement(CQLSS
TableWriter.java:589)
        at org.apache.cassandra.io.sstable.CQLSSTableWriter.access$000(CQLSSTabl
eWriter.java:102)
        at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.using(CQLSST
ableWriter.java:445)
        at CassandraJsonImporter.main(Cassand
raJsonImporter.java:66)
{code}

I'm currently testing it with 3.7 version, my POM looks like this:
{code}
<dependency>
    <groupId>org.apache.cassandra</groupId>
    <artifactId>cassandra-all</artifactId>
    <version>3.7</version>
</dependency>

<dependency>
    <groupId>org.apache.cassandra</groupId>
    <artifactId>cassandra-clientutil</artifactId>
    <version>3.7</version>
</dependency>
<dependency>
  <groupId>com.datastax.cassandra</groupId>
  <artifactId>cassandra-driver-core</artifactId>
  <version>3.0.0</version>
</dependency>
{code}

It has been working with 3.0.8 versions in the POM, but that version is somehow not including
the UDT support? 

I want to use UPDATE instead of INSERT because I need to append data to lists and do not want
to overwrite existing data in the lists. 

  was:
CQLSSTableWriter throws Exception when trying to use Update statement.
Has been working fine in previous versions for me.

Code:
{code}
	public static void main(String[] args) throws IOException {
		final String KS = "test";
		final String TABLE = "data";

		final String schema = "CREATE TABLE " + KS + "." + TABLE
				+ "(k text, c1 text, c2 text, c3 text, v text, primary key(k, c1,c2,c3))";

		final String query = "UPDATE " + KS + "." + TABLE + " SET v = ? WHERE k = ? and c1 = ? and
c2 = ?";

		File dataDir = new File(...);

		CQLSSTableWriter writer = CQLSSTableWriter.builder().inDirectory(dataDir).forTable(schema).using(query).build();
//Exception here (see below) 

		HashMap<String, Object> row = new HashMap<>();

		row.put("k", "a");
		row.put("c1", "a");
		row.put("c2", "a");
		row.put("c3", "a");
		row.put("v", "v");

		writer.addRow(row);
		writer.close();

	}

{code}

Exception:
{code}
14:51:00.461 [main] INFO  o.a.cassandra.cql3.QueryProcessor - Initialized prepar
ed statement caches with 0 MB (native) and 0 MB (Thrift)
Exception in thread "main" java.lang.IllegalArgumentException: Invalid query, mu
st be a INSERT statement but was: class org.apache.cassandra.cql3.statements.Upd
ateStatement$ParsedUpdate
        at org.apache.cassandra.io.sstable.CQLSSTableWriter.parseStatement(CQLSS
TableWriter.java:589)
        at org.apache.cassandra.io.sstable.CQLSSTableWriter.access$000(CQLSSTabl
eWriter.java:102)
        at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.using(CQLSST
ableWriter.java:445)
        at CassandraJsonImporter.main(Cassand
raJsonImporter.java:66)
{code}

I'm currently testing it with 3.7 version, my POM looks like this:
{code}
<dependency>
    <groupId>org.apache.cassandra</groupId>
    <artifactId>cassandra-all</artifactId>
    <version>3.7</version>
</dependency>

<dependency>
    <groupId>org.apache.cassandra</groupId>
    <artifactId>cassandra-clientutil</artifactId>
    <version>3.7</version>
</dependency>
{code}

It has been working with 3.0.8 versions in the POM, but that version is somehow not including
the UDT support? 

I want to use UPDATE instead of INSERT because I need to append data to lists and do not want
to overwrite existing data in the lists. 


> CQLSSTableWriter does not allow Update statement
> ------------------------------------------------
>
>                 Key: CASSANDRA-12450
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12450
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Streaming and Messaging
>            Reporter: Kuku1
>
> CQLSSTableWriter throws Exception when trying to use Update statement.
> Has been working fine in previous versions for me.
> Code:
> {code}
> 	public static void main(String[] args) throws IOException {
> 		final String KS = "test";
> 		final String TABLE = "data";
> 		final String schema = "CREATE TABLE " + KS + "." + TABLE
> 				+ "(k text, c1 text, c2 text, c3 text, v text, primary key(k, c1,c2,c3))";
> 		final String query = "UPDATE " + KS + "." + TABLE + " SET v = ? WHERE k = ? and c1
= ? and c2 = ?";
> 		File dataDir = new File(...);
> 		CQLSSTableWriter writer = CQLSSTableWriter.builder().inDirectory(dataDir).forTable(schema).using(query).build();
//Exception here (see below) 
> 		HashMap<String, Object> row = new HashMap<>();
> 		row.put("k", "a");
> 		row.put("c1", "a");
> 		row.put("c2", "a");
> 		row.put("c3", "a");
> 		row.put("v", "v");
> 		writer.addRow(row);
> 		writer.close();
> 	}
> {code}
> Exception:
> {code}
> 14:51:00.461 [main] INFO  o.a.cassandra.cql3.QueryProcessor - Initialized prepar
> ed statement caches with 0 MB (native) and 0 MB (Thrift)
> Exception in thread "main" java.lang.IllegalArgumentException: Invalid query, mu
> st be a INSERT statement but was: class org.apache.cassandra.cql3.statements.Upd
> ateStatement$ParsedUpdate
>         at org.apache.cassandra.io.sstable.CQLSSTableWriter.parseStatement(CQLSS
> TableWriter.java:589)
>         at org.apache.cassandra.io.sstable.CQLSSTableWriter.access$000(CQLSSTabl
> eWriter.java:102)
>         at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.using(CQLSST
> ableWriter.java:445)
>         at CassandraJsonImporter.main(Cassand
> raJsonImporter.java:66)
> {code}
> I'm currently testing it with 3.7 version, my POM looks like this:
> {code}
> <dependency>
>     <groupId>org.apache.cassandra</groupId>
>     <artifactId>cassandra-all</artifactId>
>     <version>3.7</version>
> </dependency>
> <dependency>
>     <groupId>org.apache.cassandra</groupId>
>     <artifactId>cassandra-clientutil</artifactId>
>     <version>3.7</version>
> </dependency>
> <dependency>
>   <groupId>com.datastax.cassandra</groupId>
>   <artifactId>cassandra-driver-core</artifactId>
>   <version>3.0.0</version>
> </dependency>
> {code}
> It has been working with 3.0.8 versions in the POM, but that version is somehow not including
the UDT support? 
> I want to use UPDATE instead of INSERT because I need to append data to lists and do
not want to overwrite existing data in the lists. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message