relops / cqlc Goto Github PK
View Code? Open in Web Editor NEWcqlc generates Go code from your Cassandra schema so that you can write type safe CQL statements in Go with a natural query syntax.
License: Other
cqlc generates Go code from your Cassandra schema so that you can write type safe CQL statements in Go with a natural query syntax.
License: Other
I'm seeing occasional nil pointer dereferences in render.go (line 81) that causes my entire webapp to crash:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x30 pc=0x708767]
goroutine 4573 [running]:
github.com/relops/cqlc/cqlc.renderInsert(0xc208083ce0, 0xc210e55ab0)
/home/ubuntu/go/src/github.com/relops/cqlc/cqlc/render.go:81 +0x77
github.com/relops/cqlc/cqlc.(_Context).RenderCQL(0xc208083ce0, 0x0, 0x0, 0x0, 0x0)
/home/ubuntu/go/src/github.com/relops/cqlc/cqlc/cqlc.go:570 +0x1c1
github.com/relops/cqlc/cqlc.BuildStatement(0xc208083ce0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/ubuntu/go/src/github.com/relops/cqlc/cqlc/cqlc.go:525 +0x8a
github.com/relops/cqlc/cqlc.(_Context).Exec(0xc208083ce0, 0xc208094160, 0x0, 0x0)
/home/ubuntu/go/src/github.com/relops/cqlc/cqlc/cqlc.go:464 +0x43
First off thanks to all developers for making this library. It is really useful. I would request you to generate struct tags for easier json or gocql conversion/usage.
Before using cqlc I used my own structs like the following:
type user struct {
Username string `json:"username" cql:"username"`
}
This would be very helpful for using mentioned libraries.
I'm new to Cassandra (version 2.2.1) and I've been using http://relops.com/cqlc/start/ to get me started with accessing it from Go. I'm able to create the keyspace using the linked schema.cql, but when I run the cqlc command in the example, I get the error: " Error querying table schema: Undefined name key_aliases in selection clause".
What is wrong? Why isn't it working?
Right now, both the Store()
and Add()
methods accept a cqlc.TableBinding
as an argument. If you pass a TableBinding
instance for a counter table to the Store()
method, there is no compile time check. Instead, you get the following run time error from Cassandra:
INSERT statement are not allowed on counter tables, use UPDATE instead
I'm using generated bindings from cqlc and pass session object for queries. This works fine but after a while, on query, returns "connection reset error" while while session.Closed api returns false.
sample query with error message is below:
present, e := ctx.Select().From(FOOTABLE).Where(
FOOTABLE.TENANT.Eq(tenant), FOOTABLE.NS.Eq(ns)).Into(FOOTABLE.To(&foo)).
FetchOne(session)
read tcp 10.160.105.22:34614->10.146.86.33:9042: read: connection reset by peer
My understanding is session object should re-establish session upon failure but in this case probably it is not able to detect connection reset ? Any pointers on handling this scenario. thanks..
A similar issue was posted, though this is based on using map keys as an index.
create table t (
x int,
y int,
z map<varchar,varchar>,
primary key (x,y)
);
CREATE INDEX ON t (KEYS(z));
It should generate methods for the EqualityStringStringMapColumn interface, which doesn't appear to exist.
I couldn't find any existing support for this. Many apologies if I've missed something.
Schemas that use "blob" data type fail:
Unmapped data type: org.apache.cassandra.db.marshal.BytesType
2014/02/05 15:13:31 3:14: expected ';', found '/'
(the second error is a gofmt error)
Hi.
I would like to try your tutorial on this page http://relops.com/cqlc/start/ .
But the schema file linked that page is 403 Forbidden so I can't fetch it.
http://relops.com/cqlc/start/some_schema
Can you fix it please?
Please see issues at:
cqlc is suffering from the same issue, I am not getting all rows from my query. cqlc must be using * or some query preparation which is causing this. Can we force cqlc to use column names in query.
Thanks
I am facing this when I am trying to do SELECT using WHERE clause. Any ideas what this is about?
This is my query:
ctx := cqlc.NewContext()
iter, err := ctx.Select().
From(A).
Where(
A.X.To(true),
A.Y.Eq(cityID)).
Fetch(c.session)
X is a boolean column
If an error occurs within the implementation of the a result set callback, there is no clean way to propagate this error to the invoking loop. Maybe the callback should return false if should not continue? But we still need to pass the error back up to the caller.
Unmapped data type: org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType)
Unmapped data type: org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType)
2014/03/25 22:33:32 61:55: expected type, found ')' (and 3 more errors)
make: *** [generated_schema.go] Error 1
I can see there is a function to SetStringStringMap . This method Sets the entite map but doesn't update the existing map. Is there any function that I can use to update the existing map?
I'm going to call a user-defined aggregate function that I've created in Cassandra. It looks like I'll have to use gocql directly to do this. Has anyone tried any other way of doing it with cqlc?
../gocode/src/github.com/relops/cqlc/generator/template.go:50: undefined: gocql.CLUSTERING_KEY
../gocode/src/github.com/relops/cqlc/generator/template.go:54: undefined: gocql.PARTITION_KEY
../gocode/src/github.com/relops/cqlc/generator/template.go:59: undefined: gocql.PARTITION_KEY
../gocode/src/github.com/relops/cqlc/generator/template.go:62: undefined: gocql.CLUSTERING_KEY
../gocode/src/github.com/relops/cqlc/generator/template.go:85: undefined: gocql.CLUSTERING_KEY
../gocode/src/github.com/relops/cqlc/generator/template.go:91: undefined: gocql.PARTITION_KEY
I'm not too sure how practical this example is, but the following construct will break the code generator:
create table t (
x int,
y int,
z int,
primary key ((x,y),z)
);
create index t_by_y on t(y)
generated_schema.go:17490: (*TYColumn).Eq redeclared in this block
previous declaration at generated_schema.go:17484
@0x6e6562 I had to change the gocql library that is being used inside cqlc to our internal gocql library. How exactly should I rebuild cqlc to make this change?
e72de39 added the Apply(...ColumnBindings)
for generating UPSERTs using ColumnBindings. This is probably messy, since you need to use the To()
method to create the binding, which accepts a destination pointer. Whilst this works, I think it would be clearer to offer an explicit non-pointer method such as From()
. If we were to do this, we'd probably need to create a specialized type of ColumnBinding to avoid overloading the legal arguments for To()
and From()
.
This tool looks great and I would love to use it. When I try install it I get compilation errors. I'm not sure if I'm doing something wrong or what. In this example I made a new empty $GOPATH
to be sure there was not some weird dependency issue.
~ ᐳ rm -rf tmp
~ ᐳ mkdir tmp
~ ᐳ export GOPATH=$PWD/tmp
~ ᐳ cd $GOPATH
~/tmp ᐳ ls
~/tmp ᐳ go get github.com/relops/cqlc
# github.com/relops/cqlc/generator
src/github.com/relops/cqlc/generator/generator.go:165: t.Type undefined (type *gocql.TypeInfo has no field or method Type)
src/github.com/relops/cqlc/generator/generator.go:175: invalid case gocql.TypeList in switch on t.Type (mismatched types int and func() gocql.Type)
src/github.com/relops/cqlc/generator/generator.go:175: invalid case gocql.TypeSet in switch on t.Type (mismatched types int and func() gocql.Type)
src/github.com/relops/cqlc/generator/generator.go:176: t.Elem undefined (type gocql.TypeInfo has no field or method Elem)
src/github.com/relops/cqlc/generator/generator.go:177: invalid case gocql.TypeMap in switch on t.Type (mismatched types int and func() gocql.Type)
src/github.com/relops/cqlc/generator/generator.go:178: t.Key undefined (type gocql.TypeInfo has no field or method Key)
src/github.com/relops/cqlc/generator/generator.go:179: t.Elem undefined (type gocql.TypeInfo has no field or method Elem)
src/github.com/relops/cqlc/generator/template.go:46: invalid operation: c.Type.Type == gocql.TypeCounter (mismatched types func() gocql.Type and int)
src/github.com/relops/cqlc/generator/template.go:71: invalid operation: c.Type.Type == gocql.TypeList (mismatched types func() gocql.Type and int)
src/github.com/relops/cqlc/generator/template.go:71: invalid operation: c.Type.Type == gocql.TypeSet (mismatched types func() gocql.Type and int)
src/github.com/relops/cqlc/generator/template.go:71: too many errors
Do you have any advice?
steps to reproduce:
CREATE TYPE testtype (
name text,
);
CREATE TABLE testtable (
id int,
connections map<text,frozen<testtype>>,
PRIMARY KEY (id)
);
cqlc run results in: expected type, found ')' (and 5 more errors)
In my Cassandra database for a particular query, I have 8 records, and I am using relops/cqlc library to query.
When I query with limit = 8, it returns 8 records with a PageState which is to be used as page token for the next set of results. First of all, I don't think it should have returned that PageState. And also as expected when I query again with that page_token and the same query parameters, it returns no data.
This is a representative of the way I am using to query
query, err := cx.Select().From(db.MY_TABLE).Where(db.MY_TABLE.NAME.Eq(name), db.MY_TABLE.EV_START.Ge(begin), db.MY_TABLE.EV_START.Lt(end)).Prepare(cass)
query.PageSize(8)
iter := query.Iter()
data, err = db.BindMyTable(iter)
err = iter.Close()
next_page_token = iter.PageState()
*cass is a gocql.Session
Why is it returning a value for the next_page_token?
The same thing does not happen if I increase the limit by one more, say 9.
Did someone else face a similar issue? Any hints as to what might be the issue?
command go get github.com/relops/cqlc
failed with the following output :
$GOPATH/github.com/relops/cqlc/generator/template.go:50: undefined: gocql.CLUSTERING_KEY
$GOPATH/github.com/relops/cqlc/generator/template.go:54: undefined: gocql.PARTITION_KEY
$GOPATH/github.com/relops/cqlc/generator/template.go:59: undefined: gocql.PARTITION_KEY
$GOPATH/github.com/relops/cqlc/generator/template.go:62: undefined: gocql.CLUSTERING_KEY
$GOPATH/github.com/relops/cqlc/generator/template.go:85: undefined: gocql.CLUSTERING_KEY
$GOPATH/github.com/relops/cqlc/generator/template.go:91: undefined: gocql.PARTITION_KEY
Same for command go build
. Any clue ?
Thanks
I'm trying to generate the code in command line however I get the following error:
2016/07/05 15:24:33 gocql: unable to dial control conn 127.0.0.1:9042: gocql: error on stream 0: Invalid or unsupported protocol version (2); the lowest supported version is 3 and the greatest is 4
2016/07/05 15:24:33 Connect error%!(EXTRA *errors.errorString=gocql: unable to create session: control: unable to connect to initial hosts: gocql: error on stream 0: Invalid or unsupported protocol version (2); the lowest supported version is 3 and the greatest is 4)
I'm using Cassandra 3.0.7 on Docker, gocql is able to connect just fine if I switch to Protocol 4, however I don't see any parameter for cqlc to change Protocol in command line
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.