001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2011-2011 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.olap;
011
012import java.io.PrintWriter;
013
014/**
015 * Explain statement.
016 *
017 * @author jhyde
018 */
019public class Explain extends QueryPart {
020    private final QueryPart query;
021
022    /**
023     * Creates an Explain statement.
024     *
025     * @param query Query (SELECT or DRILLTHROUGH)
026     */
027    Explain(
028        QueryPart query)
029    {
030        this.query = query;
031        assert this.query != null;
032        assert this.query instanceof Query
033            || this.query instanceof DrillThrough;
034    }
035
036    @Override
037    public void unparse(PrintWriter pw) {
038        pw.print("EXPLAIN PLAN FOR ");
039        query.unparse(pw);
040    }
041
042    @Override
043    public Object[] getChildren() {
044        return new Object[] {query};
045    }
046
047    public QueryPart getQuery() {
048        return query;
049    }
050}
051
052// End Explain.java