Description
We currently get a NPE for this:
gremlin> g.V().sample(1).by("age") java.lang.NullPointerException Type ':help' or ':h' for help. Display stack trace? [yN]
Since sample() is a filter, it seems intuitive that it could remove traversers that don't resolve in the by(). Of course, that changes the current semantics when the sample size is greater than or equal to the size of the traverser set:
gremlin> g.V().sample(6).by("age")
==>v[1]
==>v[2]
==>v[3]
==>v[4]
==>v[5]
==>v[6]
As an aside, we might also improve this error messaging:
gremlin> g.V().sample(1).by("name") class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap') Type ':help' or ':h' for help. Display stack trace? [yN]
As this would change Gremlin semantics a bit, it should target the next breaking version.