You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error in case the user forgets to coerce to array #969
RqlRuntimeError: Expected type DATUM but found SEQUENCE:
OPAQUE VALUE SEQUENCE in:
{value: r.db("cakemeter").table("stars").filter({repo: "rethinkdb"}).map(function(var_0) { return r.row("id"); })}
^^
Questions:
Is the backtrace broken? (javascript driver)
Is opaque sequence a term we want to keep?
If yes we should document it
If no, we should replace it.
Can we make the message a little more friendly like with an extra "Did you forget to coerce to an array?"
irb(main):014:0> r.expr({"value"=>r.db("cakemeter").table("stars").filter("repo"=>"rethinkdb")}).map{ |doc| doc["id"]}.run()RethinkDB::RqlRuntimeError: ExpectedtypeDATUMbutfoundSELECTION:
OPAQUEVALUESELECTIONBacktrace:
r({:value=>r.db("cakemeter").table("stars").filter(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{:repo=>"rethinkdb"}
^^^^^^^^^^^^^^^^^^^^^^
)}).map{|var_1|
^
var_1["id"]}Erroneous_Portion_Constructed:
from(irb):14:in`irb_binding' from /usr/lib/ruby/2.0.0/irb/workspace.rb:86:in `eval' from /usr/lib/ruby/2.0.0/irb/workspace.rb:86:in `evaluate'from/usr/lib/ruby/2.0.0/irb/context.rb:380:in`evaluate' from /usr/lib/ruby/2.0.0/irb.rb:492:in `block(2levels)ineval_input' from /usr/lib/ruby/2.0.0/irb.rb:624:in `signal_status'from/usr/lib/ruby/2.0.0/irb.rb:489:in`block in eval_input' from /usr/lib/ruby/2.0.0/irb/ruby-lex.rb:247:in `block(2levels)ineach_top_level_statement' from /usr/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in `loop'from/usr/lib/ruby/2.0.0/irb/ruby-lex.rb:233:in`block in each_top_level_statement' from /usr/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `catch' from /usr/lib/ruby/2.0.0/irb/ruby-lex.rb:232:in `each_top_level_statement'from/usr/lib/ruby/2.0.0/irb.rb:488:in`eval_input' from /usr/lib/ruby/2.0.0/irb.rb:397:in `blockinstart' from /usr/lib/ruby/2.0.0/irb.rb:396:in `catch'from/usr/lib/ruby/2.0.0/irb.rb:396:in`start' from /usr/bin/irb:12:in `<main>'Called: from /home/michel/.gem/ruby/2.0.0/gems/rethinkdb-1.5.0.0/lib/shim.rb:44:in `rescue in response_to_native'from/home/michel/.gem/ruby/2.0.0/gems/rethinkdb-1.5.0.0/lib/shim.rb:27:in`response_to_native' from /home/michel/.gem/ruby/2.0.0/gems/rethinkdb-1.5.0.0/lib/net.rb:129:in `run' from /home/michel/.gem/ruby/2.0.0/gems/rethinkdb-1.5.0.0/lib/net.rb:26:in `run'from(irb):14from/usr/bin/irb:12:in `<main>'
I think this should be broken out into two issues: a "fix the backtrace" issue assigned to @wmrowan and a "fix the error message" issue assigned to me.
There's also some question of if we want to recommend to people that they coerce to array here. Looking at the query @neumino wrote there if he were to follow that advice it's likely he's going to just wind up running afoul of the OOM killer and what he really wants to do is restructure the query to return a stream. That's hard to recommend though.
Also do we have a static limit on the size of arrays? That would at least make it unlikely for such a query to crash the server.
There's also of course the other solution to this problem which is that we could make it so this isn't an error. I actually think that might be worth considering in the future since stuff like this has come up a few times.
I wouldn't want to do that without adding a limit to array sizes. I wouldn't want to do it then, either, because I'm worried that people will write and test queries on a small dataset, then deploy to production, and their queries will mysteriously start failing once their table gets big enough to trip the array size limit.
I don't think a lot of people will have to use coerce (which is why I tagged in backlog).
I think the current behavior is fine as long as the error is a little more user friendly (it's the first time I see the term "opaque sequence".
@coffeemug wanted to have a error/troubleshooting page on the website, so we could provide a link to people to explaining why they need to coerce and the risks. That would be a good case.
@mlucy you misunderstand. I'm saying you never have to deal with arrays at all. If you run: {"foo" : r.table("foo"), "bar" : r.table("bar"}
You get back a dict with cursor objects as the values (and strings as the keys). It would require moving the protobuf file around a bit. But I actually don't see any reason it's not doable and I think it might save people having to hit snags in the type system.
Also this has some interesting effects on other issues for example if you could return more than one stream from the same query then r.table("foo").group(...) could actually return some very meaningful and useful results. (Although there are some other issues with this.)
@jdoliner -- allowing sequences to exist inside of data introduces a whole host of problems. Off the top of my head:
How do you return them to the user? All at once, or do you have some sort of composite cursor? (As @neumino points out, in languages that can't block the latter solution is really clunky.)
What do you do to forbid people from accessing the data multiple times in RQL? What if the enclosing object is stored in a variable?
What do you do if people try to compare two such objects? Do you consume the stream so it can't be accessed again? Or do you force the whole thing into memory?
I was imagining that {"foo" : r.table("foo"), "bar" : r.table("bar"} would return the same thing as: {"foo" : r.table("foo").run(), "bar" : r.table("bar").run()}. I'm unclear on why you'd need a composite cursor here.
What if the enclosing object is stored in a variable?
We could just disallow storing data which contains streams in it in variables. It might be a bit of a pain to traverse the object looking for streams but it doesn't seem impossible to me.
What do you do if people try to compare two such objects?
Similarly we'd have to disallow comparing objects that contain streams. Basically everything you can't do with a stream you now can't do with objects containing streams.
Also just to clarify I'm not suggesting a timeline here but I do think it might let us do some interesting things so I think it's worth thinking about a bit.
@jdoliner -- {"foo" : r.table("foo").run(), "bar" : r.table("bar").run()} is what I meant by a composite cursor, because it contains multiple cursors. This isn't completely unreasonable in Python/Ruby, but in JS which can't block it would be difficult to have a reasonable interface. What would the callback take, in your mind?
I opened separate issues for the error message, the array size limit, and the backtrace problem, since this issue seems to have morphed into a discussion of whether streams should be allowed in data.
@mlucy In my mind in javascript the callback would be called once with the object so in the example we have going your callback would be called with the object {"foo" : CursorObject, "bar" : CursorObject}. Then each of those cursor objects would have an iterate method so you could say things like:
The only question is what happens now when the result of the query is a single stream. We could do what we're doing now and just say that if a query returns a single stream we automatically use the callback to iterate it. In one sense this is nice because it saves you some typing on the other hand this is something that separates the Javascript drivers from the other drivers and it makes something that's fairly reasonable in the other 2 a bit weird in javascript.
My sense is that it'll be painful for people to have to change how they handle streams at this point so we shouldn't change it but I also think that having this little wart in Javascript might be okay since being able to return multiple cursors is actually pretty nice.
Activity
coffeemug commentedon Jun 10, 2013
@neumino -- could you check what the backtrace looks like in Python and Ruby?
neumino commentedon Jun 10, 2013
For python
Ruby
neumino commentedon Jun 10, 2013
The first error was caught with the data explorer.
Using the last JavaScript driver yield the same backtrace.
mlucy commentedon Jun 10, 2013
I think this should be broken out into two issues: a "fix the backtrace" issue assigned to @wmrowan and a "fix the error message" issue assigned to me.
jdoliner commentedon Jun 10, 2013
There's also some question of if we want to recommend to people that they coerce to array here. Looking at the query @neumino wrote there if he were to follow that advice it's likely he's going to just wind up running afoul of the OOM killer and what he really wants to do is restructure the query to return a stream. That's hard to recommend though.
Also do we have a static limit on the size of arrays? That would at least make it unlikely for such a query to crash the server.
mlucy commentedon Jun 10, 2013
We did at one point, but it was an absurdly high limit and I can't seem to find it in the code any more.
jdoliner commentedon Jun 10, 2013
There's also of course the other solution to this problem which is that we could make it so this isn't an error. I actually think that might be worth considering in the future since stuff like this has come up a few times.
mlucy commentedon Jun 10, 2013
I wouldn't want to do that without adding a limit to array sizes. I wouldn't want to do it then, either, because I'm worried that people will write and test queries on a small dataset, then deploy to production, and their queries will mysteriously start failing once their table gets big enough to trip the array size limit.
neumino commentedon Jun 10, 2013
I don't think a lot of people will have to use coerce (which is why I tagged in backlog).
I think the current behavior is fine as long as the error is a little more user friendly (it's the first time I see the term "opaque sequence".
@coffeemug wanted to have a error/troubleshooting page on the website, so we could provide a link to people to explaining why they need to coerce and the risks. That would be a good case.
jdoliner commentedon Jun 10, 2013
@mlucy you misunderstand. I'm saying you never have to deal with arrays at all. If you run:
{"foo" : r.table("foo"), "bar" : r.table("bar"}You get back a dict with cursor objects as the values (and strings as the keys). It would require moving the protobuf file around a bit. But I actually don't see any reason it's not doable and I think it might save people having to hit snags in the type system.
Also this has some interesting effects on other issues for example if you could return more than one stream from the same query then
r.table("foo").group(...)could actually return some very meaningful and useful results. (Although there are some other issues with this.)neumino commentedon Jun 10, 2013
I'm strongly opposed of passing cursors inside an objects as a result because that would make the JavaScript driver unusable.
At least if it's the default behavior.
mlucy commentedon Jun 10, 2013
@jdoliner -- allowing sequences to exist inside of data introduces a whole host of problems. Off the top of my head:
jdoliner commentedon Jun 10, 2013
I was imagining that
{"foo" : r.table("foo"), "bar" : r.table("bar"}would return the same thing as:{"foo" : r.table("foo").run(), "bar" : r.table("bar").run()}. I'm unclear on why you'd need a composite cursor here.We could just disallow storing data which contains streams in it in variables. It might be a bit of a pain to traverse the object looking for streams but it doesn't seem impossible to me.
Similarly we'd have to disallow comparing objects that contain streams. Basically everything you can't do with a stream you now can't do with objects containing streams.
jdoliner commentedon Jun 10, 2013
Also just to clarify I'm not suggesting a timeline here but I do think it might let us do some interesting things so I think it's worth thinking about a bit.
jdoliner commentedon Jun 10, 2013
@neumino This would lead to a change to the javascript driver but I think it could be made usable.
mlucy commentedon Jun 10, 2013
@jdoliner --
{"foo" : r.table("foo").run(), "bar" : r.table("bar").run()}is what I meant by a composite cursor, because it contains multiple cursors. This isn't completely unreasonable in Python/Ruby, but in JS which can't block it would be difficult to have a reasonable interface. What would the callback take, in your mind?mlucy commentedon Jun 10, 2013
I opened separate issues for the error message, the array size limit, and the backtrace problem, since this issue seems to have morphed into a discussion of whether streams should be allowed in data.
jdoliner commentedon Jun 10, 2013
@mlucy In my mind in javascript the callback would be called once with the object so in the example we have going your callback would be called with the object
{"foo" : CursorObject, "bar" : CursorObject}. Then each of those cursor objects would have aniteratemethod so you could say things like:The only question is what happens now when the result of the query is a single stream. We could do what we're doing now and just say that if a query returns a single stream we automatically use the callback to iterate it. In one sense this is nice because it saves you some typing on the other hand this is something that separates the Javascript drivers from the other drivers and it makes something that's fairly reasonable in the other 2 a bit weird in javascript.
My sense is that it'll be painful for people to have to change how they handle streams at this point so we shouldn't change it but I also think that having this little wart in Javascript might be okay since being able to return multiple cursors is actually pretty nice.
srh commentedon May 17, 2017
Closing since all that's left is miscellaneous discussion about whether streams should be allowed in data, nothing resolveable here.