Repository: cayleygraph/cayley
Pull request #930 (2020-04-09 18:13:08)

LinkedQL: Centralize iterator creation to linkedql main module


<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/cayleygraph/cayley/930)
<!-- Reviewable:end -->



Patch:
diff --git a/query/linkedql/linkedql.go b/query/linkedql/linkedql.go
index d4c2363..86e8787 100644
--- a/query/linkedql/linkedql.go
+++ b/query/linkedql/linkedql.go
@@ -50,10 +50,21 @@ func (s *Session) Execute(ctx context.Context, query string, opt query.Options)
 	if err != nil {
 		return nil, err
 	}
-	step, ok := item.(IteratorStep)
+	ns := voc.Namespaces{}
+	step, ok := item.(Step)
 	if !ok {
-		return nil, errors.New("must execute a valid step")
+		return nil, errors.New("must execute a Step")
 	}
-	ns := voc.Namespaces{}
-	return step.BuildIterator(s.qs, &ns)
+	return BuildIterator(step, s.qs, &ns)
+}
+
+// BuildIterator for given Step returns a query.Iterator
+func BuildIterator(step Step, qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
+	switch s := step.(type) {
+	case IteratorStep:
+		return s.BuildIterator(qs, ns)
+	case PathStep:
+		return NewValueIteratorFromPathStep(s, qs, ns)
+	}
+	return nil, errors.New("must execute a IteratorStep or PathStep")
 }
diff --git a/query/linkedql/steps/as.go b/query/linkedql/steps/as.go
index 63642cc..032642d 100644
--- a/query/linkedql/steps/as.go
+++ b/query/linkedql/steps/as.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&As{})
 }
 
-var _ linkedql.IteratorStep = (*As)(nil)
 var _ linkedql.PathStep = (*As)(nil)
 
 // As corresponds to .tag().
@@ -26,11 +24,6 @@ func (s *As) Description() string {
 	return "assigns the resolved values of the from step to a given name. The name can be used with the Select and Documents steps to retrieve the values or to return to the values in further steps with the Back step. It resolves to the values of the from step."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *As) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *As) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/back.go b/query/linkedql/steps/back.go
index ced6360..96d69d8 100644
--- a/query/linkedql/steps/back.go
+++ b/query/linkedql/steps/back.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Back{})
 }
 
-var _ linkedql.IteratorStep = (*Back)(nil)
 var _ linkedql.PathStep = (*Back)(nil)
 
 // Back corresponds to .back().
@@ -26,11 +24,6 @@ func (s *Back) Description() string {
 	return "resolves to the values of the previous the step or the values assigned to name in a former step."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Back) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Back) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/both.go b/query/linkedql/steps/both.go
index eb75d7d..d089df7 100644
--- a/query/linkedql/steps/both.go
+++ b/query/linkedql/steps/both.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Both{})
 }
 
-var _ linkedql.IteratorStep = (*Both)(nil)
 var _ linkedql.PathStep = (*Both)(nil)
 
 // Both corresponds to .both().
@@ -26,11 +24,6 @@ func (s *Both) Description() string {
 	return "is like View but resolves to both the object values and references to the values of the given properties in via. It is the equivalent for the Union of View and ViewReverse of the same property."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Both) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Both) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/collect.go b/query/linkedql/steps/collect.go
index 5ce5f62..5aee7d8 100644
--- a/query/linkedql/steps/collect.go
+++ b/query/linkedql/steps/collect.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -13,7 +12,6 @@ func init() {
 	linkedql.Register(&Collect{})
 }
 
-var _ linkedql.IteratorStep = (*Collect)(nil)
 var _ linkedql.PathStep = (*Collect)(nil)
 
 // Collect corresponds to .view().
@@ -27,11 +25,6 @@ func (s *Collect) Description() string {
 	return "Recursively resolves values of a list (also known as RDF collection)"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Collect) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 var (
 	first  = quad.IRI("rdf:first").Full()
 	rest   = quad.IRI("rdf:rest").Full()
diff --git a/query/linkedql/steps/context.go b/query/linkedql/steps/context.go
index 7384d04..5f26c75 100644
--- a/query/linkedql/steps/context.go
+++ b/query/linkedql/steps/context.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Context{})
 }
 
-var _ linkedql.IteratorStep = (*Context)(nil)
 var _ linkedql.PathStep = (*Context)(nil)
 
 // Context corresponds to context().
@@ -38,8 +36,3 @@ func (s *Context) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path,
 	}
 	return fromPath, nil
 }
-
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Context) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
diff --git a/query/linkedql/steps/count.go b/query/linkedql/steps/count.go
index 33c378e..e9762db 100644
--- a/query/linkedql/steps/count.go
+++ b/query/linkedql/steps/count.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Count{})
 }
 
-var _ linkedql.IteratorStep = (*Count)(nil)
 var _ linkedql.PathStep = (*Count)(nil)
 
 // Count corresponds to .count().
@@ -25,11 +23,6 @@ func (s *Count) Description() string {
 	return "resolves to the number of the resolved values of the from step"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Count) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Count) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/difference.go b/query/linkedql/steps/difference.go
index e4d10c1..78c8eb1 100644
--- a/query/linkedql/steps/difference.go
+++ b/query/linkedql/steps/difference.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Difference{})
 }
 
-var _ linkedql.IteratorStep = (*Difference)(nil)
 var _ linkedql.PathStep = (*Difference)(nil)
 
 // Difference corresponds to .difference().
@@ -26,11 +24,6 @@ func (s *Difference) Description() string {
 	return "resolves to all the values resolved by the from step different then the values resolved by the provided steps. Caution: it might be slow to execute."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Difference) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Difference) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/follow.go b/query/linkedql/steps/follow.go
index 90b27a2..78dce6b 100644
--- a/query/linkedql/steps/follow.go
+++ b/query/linkedql/steps/follow.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Follow{})
 }
 
-var _ linkedql.IteratorStep = (*Follow)(nil)
 var _ linkedql.PathStep = (*Follow)(nil)
 
 // Follow corresponds to .follow().
@@ -26,11 +24,6 @@ func (s *Follow) Description() string {
 	return "is the way to use a path prepared with Morphism. Applies the path chain on the morphism object to the current path. Starts as if at the g.M() and follows through the morphism path."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Follow) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Follow) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/greater_than.go b/query/linkedql/steps/greater_than.go
index 20d7e9e..52cab33 100644
--- a/query/linkedql/steps/greater_than.go
+++ b/query/linkedql/steps/greater_than.go
@@ -3,7 +3,6 @@ package steps
 import (
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -14,7 +13,6 @@ func init() {
 	linkedql.Register(&GreaterThan{})
 }
 
-var _ linkedql.IteratorStep = (*GreaterThan)(nil)
 var _ linkedql.PathStep = (*GreaterThan)(nil)
 
 // GreaterThan corresponds to gt().
@@ -28,11 +26,6 @@ func (s *GreaterThan) Description() string {
 	return "Greater than equals filters out values that are not greater than given value"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *GreaterThan) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *GreaterThan) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/greater_than_equals.go b/query/linkedql/steps/greater_than_equals.go
index fb81c8c..50b36a9 100644
--- a/query/linkedql/steps/greater_than_equals.go
+++ b/query/linkedql/steps/greater_than_equals.go
@@ -3,7 +3,6 @@ package steps
 import (
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -14,7 +13,6 @@ func init() {
 	linkedql.Register(&GreaterThanEquals{})
 }
 
-var _ linkedql.IteratorStep = (*GreaterThanEquals)(nil)
 var _ linkedql.PathStep = (*GreaterThanEquals)(nil)
 
 // GreaterThanEquals corresponds to gte().
@@ -28,11 +26,6 @@ func (s *GreaterThanEquals) Description() string {
 	return "Greater than equals filters out values that are not greater than or equal given value"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *GreaterThanEquals) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *GreaterThanEquals) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/has.go b/query/linkedql/steps/has.go
index 459bac0..d8b47a7 100644
--- a/query/linkedql/steps/has.go
+++ b/query/linkedql/steps/has.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -13,7 +12,6 @@ func init() {
 	linkedql.Register(&Has{})
 }
 
-var _ linkedql.IteratorStep = (*Has)(nil)
 var _ linkedql.PathStep = (*Has)(nil)
 
 // Has corresponds to .has().
@@ -28,11 +26,6 @@ func (s *Has) Description() string {
 	return "filters all paths which are, at this point, on the subject for the given predicate and object, but do not follow the path, merely filter the possible paths. Usually useful for starting with all nodes, or limiting to a subset depending on some predicate/value pair."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Has) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Has) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/has_reverse.go b/query/linkedql/steps/has_reverse.go
index 2c6287c..4ae5a6b 100644
--- a/query/linkedql/steps/has_reverse.go
+++ b/query/linkedql/steps/has_reverse.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -13,7 +12,6 @@ func init() {
 	linkedql.Register(&HasReverse{})
 }
 
-var _ linkedql.IteratorStep = (*HasReverse)(nil)
 var _ linkedql.PathStep = (*HasReverse)(nil)
 
 // HasReverse corresponds to .hasR().
@@ -28,11 +26,6 @@ func (s *HasReverse) Description() string {
 	return "is the same as Has, but sets constraint in reverse direction."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *HasReverse) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *HasReverse) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/in.go b/query/linkedql/steps/in.go
index b9d4c26..5cfd50d 100644
--- a/query/linkedql/steps/in.go
+++ b/query/linkedql/steps/in.go
@@ -8,7 +8,6 @@ func init() {
 	linkedql.Register(&In{})
 }
 
-var _ linkedql.IteratorStep = (*In)(nil)
 var _ linkedql.PathStep = (*In)(nil)
 
 // In is an alias for ViewReverse.
diff --git a/query/linkedql/steps/intersect.go b/query/linkedql/steps/intersect.go
index 69ad752..9e48671 100644
--- a/query/linkedql/steps/intersect.go
+++ b/query/linkedql/steps/intersect.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Intersect{})
 }
 
-var _ linkedql.IteratorStep = (*Intersect)(nil)
 var _ linkedql.PathStep = (*Intersect)(nil)
 
 // Intersect represents .intersect() and .and().
@@ -26,11 +24,6 @@ func (s *Intersect) Description() string {
 	return "resolves to all the same values resolved by the from step and the provided steps."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Intersect) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Intersect) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/labels.go b/query/linkedql/steps/labels.go
index 51979ff..972f94c 100644
--- a/query/linkedql/steps/labels.go
+++ b/query/linkedql/steps/labels.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Labels{})
 }
 
-var _ linkedql.IteratorStep = (*Labels)(nil)
 var _ linkedql.PathStep = (*Labels)(nil)
 
 // Labels corresponds to .labels().
@@ -25,11 +23,6 @@ func (s *Labels) Description() string {
 	return "gets the list of inbound and outbound quad labels"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Labels) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Labels) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/less_than.go b/query/linkedql/steps/less_than.go
index 2c4b76e..32cbd82 100644
--- a/query/linkedql/steps/less_than.go
+++ b/query/linkedql/steps/less_than.go
@@ -3,7 +3,6 @@ package steps
 import (
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -14,7 +13,6 @@ func init() {
 	linkedql.Register(&LessThan{})
 }
 
-var _ linkedql.IteratorStep = (*LessThan)(nil)
 var _ linkedql.PathStep = (*LessThan)(nil)
 
 // LessThan corresponds to lt().
@@ -28,11 +26,6 @@ func (s *LessThan) Description() string {
 	return "Less than filters out values that are not less than given value"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *LessThan) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *LessThan) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/less_than_equals.go b/query/linkedql/steps/less_than_equals.go
index c994cc8..65c02b4 100644
--- a/query/linkedql/steps/less_than_equals.go
+++ b/query/linkedql/steps/less_than_equals.go
@@ -3,7 +3,6 @@ package steps
 import (
 	"github.com/cayleygraph/cayley/graph"
 	"github.com/cayleygraph/cayley/graph/iterator"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -14,7 +13,6 @@ func init() {
 	linkedql.Register(&LessThanEquals{})
 }
 
-var _ linkedql.IteratorStep = (*LessThanEquals)(nil)
 var _ linkedql.PathStep = (*LessThanEquals)(nil)
 
 // LessThanEquals corresponds to lte().
@@ -28,11 +26,6 @@ func (s *LessThanEquals) Description() string {
 	return "Less than equals filters out values that are not less than or equal given value"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *LessThanEquals) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *LessThanEquals) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/like.go b/query/linkedql/steps/like.go
index 9de37aa..875d944 100644
--- a/query/linkedql/steps/like.go
+++ b/query/linkedql/steps/like.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/cayley/query/shape"
@@ -13,7 +12,6 @@ func init() {
 	linkedql.Register(&Like{})
 }
 
-var _ linkedql.IteratorStep = (*Like)(nil)
 var _ linkedql.PathStep = (*Like)(nil)
 
 // Like corresponds to like().
@@ -27,11 +25,6 @@ func (s *Like) Description() string {
 	return "Like filters out values that do not match given pattern."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Like) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements PathStep.
 func (s *Like) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/limit.go b/query/linkedql/steps/limit.go
index 88b5ec6..80627e7 100644
--- a/query/linkedql/steps/limit.go
+++ b/query/linkedql/steps/limit.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Limit{})
 }
 
-var _ linkedql.IteratorStep = (*Limit)(nil)
 var _ linkedql.PathStep = (*Limit)(nil)
 
 // Limit corresponds to .limit().
@@ -26,11 +24,6 @@ func (s *Limit) Description() string {
 	return "limits a number of nodes for current path."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Limit) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Limit) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/match.go b/query/linkedql/steps/match.go
index 94eff58..3efa0b0 100644
--- a/query/linkedql/steps/match.go
+++ b/query/linkedql/steps/match.go
@@ -4,7 +4,6 @@ import (
 	"fmt"
 
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -18,7 +17,6 @@ func init() {
 	linkedql.Register(&Match{})
 }
 
-var _ linkedql.IteratorStep = (*Match)(nil)
 var _ linkedql.PathStep = (*Match)(nil)
 
 // Match corresponds to .has().
@@ -32,11 +30,6 @@ func (s *Match) Description() string {
 	return "filters all paths which are, at this point, on the subject for the given predicate and object, but do not follow the path, merely filter the possible paths. Usually useful for starting with all nodes, or limiting to a subset depending on some predicate/value pair."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Match) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Match) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	var p *path.Path
diff --git a/query/linkedql/steps/optional.go b/query/linkedql/steps/optional.go
index 0fe2fab..f8a1808 100644
--- a/query/linkedql/steps/optional.go
+++ b/query/linkedql/steps/optional.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Optional{})
 }
 
-var _ linkedql.IteratorStep = (*Optional)(nil)
 var _ linkedql.PathStep = (*Optional)(nil)
 
 // Optional corresponds to .optional().
@@ -26,11 +24,6 @@ func (s *Optional) Description() string {
 	return "attempts to follow the given path from the current entity / value, if fails the entity / value will still be kept in the results"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Optional) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Optional) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/order.go b/query/linkedql/steps/order.go
index 8e88240..5bb459d 100644
--- a/query/linkedql/steps/order.go
+++ b/query/linkedql/steps/order.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Order{})
 }
 
-var _ linkedql.IteratorStep = (*Order)(nil)
 var _ linkedql.PathStep = (*Order)(nil)
 
 // Order corresponds to .order().
@@ -25,11 +23,6 @@ func (s *Order) Description() string {
 	return "sorts the results in ascending order according to the current entity / value"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Order) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Order) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/out.go b/query/linkedql/steps/out.go
index 7230184..6346620 100644
--- a/query/linkedql/steps/out.go
+++ b/query/linkedql/steps/out.go
@@ -8,7 +8,6 @@ func init() {
 	linkedql.Register(&Out{})
 }
 
-var _ linkedql.IteratorStep = (*Out)(nil)
 var _ linkedql.PathStep = (*Out)(nil)
 
 // Out is an alias for View.
diff --git a/query/linkedql/steps/properties.go b/query/linkedql/steps/properties.go
index aadc4bb..d98f90b 100644
--- a/query/linkedql/steps/properties.go
+++ b/query/linkedql/steps/properties.go
@@ -4,7 +4,6 @@ import (
 	"fmt"
 
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -15,7 +14,6 @@ func init() {
 	linkedql.Register(&Properties{})
 }
 
-var _ linkedql.IteratorStep = (*Properties)(nil)
 var _ linkedql.PathStep = (*Properties)(nil)
 
 // Properties corresponds to .properties().
@@ -29,12 +27,6 @@ func (s *Properties) Description() string {
 	return "adds tags for all properties of the current entity"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-// TODO(iddan): Default tag to Via.
-func (s *Properties) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 func resolveNames(names *linkedql.PropertyPath) (linkedql.PropertyIRIs, error) {
 	if names == nil {
 		return nil, fmt.Errorf("Not implemented: should tag all properties")
diff --git a/query/linkedql/steps/property_names.go b/query/linkedql/steps/property_names.go
index f2abce5..c75b51a 100644
--- a/query/linkedql/steps/property_names.go
+++ b/query/linkedql/steps/property_names.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&PropertyNames{})
 }
 
-var _ linkedql.IteratorStep = (*PropertyNames)(nil)
 var _ linkedql.PathStep = (*PropertyNames)(nil)
 
 // PropertyNames corresponds to .propertyNames().
@@ -25,11 +23,6 @@ func (s *PropertyNames) Description() string {
 	return "gets the list of predicates that are pointing out from a node."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *PropertyNames) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *PropertyNames) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/property_names_as.go b/query/linkedql/steps/property_names_as.go
index 5f30ce4..f755b24 100644
--- a/query/linkedql/steps/property_names_as.go
+++ b/query/linkedql/steps/property_names_as.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&PropertyNamesAs{})
 }
 
-var _ linkedql.IteratorStep = (*PropertyNamesAs)(nil)
 var _ linkedql.PathStep = (*PropertyNamesAs)(nil)
 
 // PropertyNamesAs corresponds to .propertyNamesAs().
@@ -26,11 +24,6 @@ func (s *PropertyNamesAs) Description() string {
 	return "tags the list of predicates that are pointing out from a node."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *PropertyNamesAs) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *PropertyNamesAs) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/regexp.go b/query/linkedql/steps/regexp.go
index 504f459..ce277a3 100644
--- a/query/linkedql/steps/regexp.go
+++ b/query/linkedql/steps/regexp.go
@@ -4,7 +4,6 @@ import (
 	"regexp"
 
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -14,7 +13,6 @@ func init() {
 	linkedql.Register(&RegExp{})
 }
 
-var _ linkedql.IteratorStep = (*RegExp)(nil)
 var _ linkedql.PathStep = (*RegExp)(nil)
 
 // RegExp corresponds to regex().
@@ -29,11 +27,6 @@ func (s *RegExp) Description() string {
 	return "RegExp filters out values that do not match given pattern. If includeIRIs is set to true it matches IRIs in addition to literals."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *RegExp) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements PathStep.
 func (s *RegExp) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/reverse_properties.go b/query/linkedql/steps/reverse_properties.go
index f0380ac..601eae8 100644
--- a/query/linkedql/steps/reverse_properties.go
+++ b/query/linkedql/steps/reverse_properties.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -13,7 +12,6 @@ func init() {
 	linkedql.Register(&ReverseProperties{})
 }
 
-var _ linkedql.IteratorStep = (*ReverseProperties)(nil)
 var _ linkedql.PathStep = (*ReverseProperties)(nil)
 
 // ReverseProperties corresponds to .reverseProperties().
@@ -27,11 +25,6 @@ func (s *ReverseProperties) Description() string {
 	return "gets all the properties the current entity / value is referenced at"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *ReverseProperties) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *ReverseProperties) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/reverse_property_names.go b/query/linkedql/steps/reverse_property_names.go
index d107d05..0c7dccd 100644
--- a/query/linkedql/steps/reverse_property_names.go
+++ b/query/linkedql/steps/reverse_property_names.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&ReversePropertyNames{})
 }
 
-var _ linkedql.IteratorStep = (*ReversePropertyNames)(nil)
 var _ linkedql.PathStep = (*ReversePropertyNames)(nil)
 
 // ReversePropertyNames corresponds to .reversePropertyNames().
@@ -25,11 +23,6 @@ func (s *ReversePropertyNames) Description() string {
 	return "gets the list of predicates that are pointing in to a node."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *ReversePropertyNames) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *ReversePropertyNames) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/reverse_property_names_as.go b/query/linkedql/steps/reverse_property_names_as.go
index a44a568..f30c745 100644
--- a/query/linkedql/steps/reverse_property_names_as.go
+++ b/query/linkedql/steps/reverse_property_names_as.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&ReversePropertyNamesAs{})
 }
 
-var _ linkedql.IteratorStep = (*ReversePropertyNamesAs)(nil)
 var _ linkedql.PathStep = (*ReversePropertyNamesAs)(nil)
 
 // ReversePropertyNamesAs corresponds to .reversePropertyNamesAs().
@@ -26,11 +24,6 @@ func (s *ReversePropertyNamesAs) Description() string {
 	return "tags the list of predicates that are pointing in to a node."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *ReversePropertyNamesAs) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *ReversePropertyNamesAs) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/skip.go b/query/linkedql/steps/skip.go
index 8c47195..55e025b 100644
--- a/query/linkedql/steps/skip.go
+++ b/query/linkedql/steps/skip.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Skip{})
 }
 
-var _ linkedql.IteratorStep = (*Skip)(nil)
 var _ linkedql.PathStep = (*Skip)(nil)
 
 // Skip corresponds to .skip().
@@ -26,11 +24,6 @@ func (s *Skip) Description() string {
 	return "skips a number of nodes for current path."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Skip) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Skip) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/union.go b/query/linkedql/steps/union.go
index 5728608..1c9b981 100644
--- a/query/linkedql/steps/union.go
+++ b/query/linkedql/steps/union.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Union{})
 }
 
-var _ linkedql.IteratorStep = (*Union)(nil)
 var _ linkedql.PathStep = (*Union)(nil)
 
 // Union corresponds to .union() and .or().
@@ -26,11 +24,6 @@ func (s *Union) Description() string {
 	return "returns the combined paths of the two queries. Notice that it's per-path, not per-node. Once again, if multiple paths reach the same destination, they might have had different ways of getting there (and different tags)."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Union) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Union) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/unique.go b/query/linkedql/steps/unique.go
index 4d21c72..bc6c688 100644
--- a/query/linkedql/steps/unique.go
+++ b/query/linkedql/steps/unique.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Unique{})
 }
 
-var _ linkedql.IteratorStep = (*Unique)(nil)
 var _ linkedql.PathStep = (*Unique)(nil)
 
 // Unique corresponds to .unique().
@@ -25,11 +23,6 @@ func (s *Unique) Description() string {
 	return "removes duplicate values from the path."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Unique) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Unique) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/vertex.go b/query/linkedql/steps/vertex.go
index 8379ae5..4d58377 100644
--- a/query/linkedql/steps/vertex.go
+++ b/query/linkedql/steps/vertex.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad"
@@ -13,7 +12,6 @@ func init() {
 	linkedql.Register(&Vertex{})
 }
 
-var _ linkedql.IteratorStep = (*Vertex)(nil)
 var _ linkedql.PathStep = (*Vertex)(nil)
 
 // Vertex corresponds to g.Vertex() and g.V().
@@ -26,11 +24,6 @@ func (s *Vertex) Description() string {
 	return "resolves to all the existing objects and primitive values in the graph. If provided with values resolves to a sublist of all the existing values in the graph."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Vertex) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Vertex) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	return path.StartPath(qs, linkedql.AbsoluteValues(s.Values, ns)...), nil
diff --git a/query/linkedql/steps/visit.go b/query/linkedql/steps/visit.go
index d9329a7..460ca4c 100644
--- a/query/linkedql/steps/visit.go
+++ b/query/linkedql/steps/visit.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Visit{})
 }
 
-var _ linkedql.IteratorStep = (*Visit)(nil)
 var _ linkedql.PathStep = (*Visit)(nil)
 
 // Visit corresponds to .view().
@@ -26,11 +24,6 @@ func (s *Visit) Description() string {
 	return "resolves to the values of the given property or properties in via of the current objects. If via is a path it's resolved values will be used as properties."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Visit) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Visit) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/visit_reverse.go b/query/linkedql/steps/visit_reverse.go
index de57a15..8f3f009 100644
--- a/query/linkedql/steps/visit_reverse.go
+++ b/query/linkedql/steps/visit_reverse.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&VisitReverse{})
 }
 
-var _ linkedql.IteratorStep = (*VisitReverse)(nil)
 var _ linkedql.PathStep = (*VisitReverse)(nil)
 
 // VisitReverse corresponds to .viewReverse().
@@ -26,11 +24,6 @@ func (s *VisitReverse) Description() string {
 	return "is the inverse of View. Starting with the nodes in `path` on the object, follow the quads with predicates defined by `predicatePath` to their subjects."
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *VisitReverse) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *VisitReverse) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)
diff --git a/query/linkedql/steps/where.go b/query/linkedql/steps/where.go
index 646be2f..a30aa2f 100644
--- a/query/linkedql/steps/where.go
+++ b/query/linkedql/steps/where.go
@@ -2,7 +2,6 @@ package steps
 
 import (
 	"github.com/cayleygraph/cayley/graph"
-	"github.com/cayleygraph/cayley/query"
 	"github.com/cayleygraph/cayley/query/linkedql"
 	"github.com/cayleygraph/cayley/query/path"
 	"github.com/cayleygraph/quad/voc"
@@ -12,7 +11,6 @@ func init() {
 	linkedql.Register(&Where{})
 }
 
-var _ linkedql.IteratorStep = (*Where)(nil)
 var _ linkedql.PathStep = (*Where)(nil)
 
 // Where corresponds to .where().
@@ -26,11 +24,6 @@ func (s *Where) Description() string {
 	return "applies each provided step in steps in isolation on from"
 }
 
-// BuildIterator implements linkedql.IteratorStep.
-func (s *Where) BuildIterator(qs graph.QuadStore, ns *voc.Namespaces) (query.Iterator, error) {
-	return linkedql.NewValueIteratorFromPathStep(s, qs, ns)
-}
-
 // BuildPath implements linkedql.PathStep.
 func (s *Where) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {
 	fromPath, err := s.From.BuildPath(qs, ns)


Test patch:
diff --git a/query/linkedql/steps/steps_test.go b/query/linkedql/steps/steps_test.go
index 0f68601..ef8904f 100644
--- a/query/linkedql/steps/steps_test.go
+++ b/query/linkedql/steps/steps_test.go
@@ -38,7 +38,7 @@ func readData(data interface{}) ([]quad.Quad, error) {
 	return quads, nil
 }
 
-func readQuery(raw interface{}) (linkedql.IteratorStep, error) {
+func readQuery(raw interface{}) (linkedql.Step, error) {
 	d, err := json.Marshal(raw)
 	if err != nil {
 		return nil, err
@@ -47,9 +47,9 @@ func readQuery(raw interface{}) (linkedql.IteratorStep, error) {
 	if err != nil {
 		return nil, err
 	}
-	query, ok := q.(linkedql.IteratorStep)
+	query, ok := q.(linkedql.Step)
 	if !ok {
-		return nil, fmt.Errorf("Expected linkedql.IteratorStep")
+		return nil, fmt.Errorf("Expected linkedql.Step")
 	}
 	return query, nil
 }
@@ -84,7 +84,7 @@ func TestLinkedQL(t *testing.T) {
 			store := memstore.New(data...)
 			voc := voc.Namespaces{}
 			ctx := context.TODO()
-			iterator, err := query.BuildIterator(store, &voc)
+			iterator, err := linkedql.BuildIterator(query, store, &voc)
 			require.NoError(t, err)
 			var results []interface{}
 			for iterator.Next(ctx) {