class ExpandViews extends LogicalOperatorTransform {

    @Override
    public OperatorNode<SequenceOperator> visitSequenceOperator(OperatorNode<SequenceOperator> node) {
        // a view reference has to be in a 'SCAN'
        if (node.getOperator() != SequenceOperator.SCAN) {
            return super.visitSequenceOperator(node);
        }
        List<String> name = (List<String>) node.getArgument(0);
        List<OperatorNode<ExpressionOperator>> arguments = (List<OperatorNode<ExpressionOperator>>) node.getArgument(1);
        // a view reference has to have no arguments
        if (arguments.size() > 0) {
            // we need to continue traversing because the arguments are nodes too
            return super.visitSequenceOperator(node);
        }
        OperatorNode<SequenceOperator> view = scope.getView(name);
        if (view == null) {
            return super.visitSequenceOperator(node);
        }
        // OK, so we have a SCAN node and we know it maps to a view.
        // Make a deep copy of the view so later transforms can mutate it safely.
        view = view.copy();
        String alias = (String) node.getAnnotation("alias");
        if (alias != null) {
            view.putAnnotation("alias", alias);
        }
        return view;
    }

    public  ExpandViews(ViewRegistry scope);

}