/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.sql.planner.plan;

import com.facebook.presto.sql.planner.Symbol;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import java.util.List;

import static java.util.Objects.requireNonNull;

@JsonTypeInfo(
        use = JsonTypeInfo.Id.NAME,
        include = JsonTypeInfo.As.PROPERTY,
        property = "@type")
@JsonSubTypes({
        @JsonSubTypes.Type(value = OutputNode.class, name = "output"),
        @JsonSubTypes.Type(value = ProjectNode.class, name = "project"),
        @JsonSubTypes.Type(value = TableScanNode.class, name = "tablescan"),
        @JsonSubTypes.Type(value = ValuesNode.class, name = "values"),
        @JsonSubTypes.Type(value = AggregationNode.class, name = "aggregation"),
        @JsonSubTypes.Type(value = MarkDistinctNode.class, name = "markDistinct"),
        @JsonSubTypes.Type(value = FilterNode.class, name = "filter"),
        @JsonSubTypes.Type(value = WindowNode.class, name = "window"),
        @JsonSubTypes.Type(value = RowNumberNode.class, name = "rowNumber"),
        @JsonSubTypes.Type(value = TopNRowNumberNode.class, name = "topnRowNumber"),
        @JsonSubTypes.Type(value = LimitNode.class, name = "limit"),
        @JsonSubTypes.Type(value = DistinctLimitNode.class, name = "distinctlimit"),
        @JsonSubTypes.Type(value = TopNNode.class, name = "topn"),
        @JsonSubTypes.Type(value = SampleNode.class, name = "sample"),
        @JsonSubTypes.Type(value = SortNode.class, name = "sort"),
        @JsonSubTypes.Type(value = RemoteSourceNode.class, name = "remoteSource"),
        @JsonSubTypes.Type(value = JoinNode.class, name = "join"),
        @JsonSubTypes.Type(value = SemiJoinNode.class, name = "semijoin"),
        @JsonSubTypes.Type(value = SpatialJoinNode.class, name = "spatialjoin"),
        @JsonSubTypes.Type(value = IndexJoinNode.class, name = "indexjoin"),
        @JsonSubTypes.Type(value = IndexSourceNode.class, name = "indexsource"),
        @JsonSubTypes.Type(value = TableWriterNode.class, name = "tablewriter"),
        @JsonSubTypes.Type(value = DeleteNode.class, name = "delete"),
        @JsonSubTypes.Type(value = MetadataDeleteNode.class, name = "metadatadelete"),
        @JsonSubTypes.Type(value = TableFinishNode.class, name = "tablecommit"),
        @JsonSubTypes.Type(value = UnnestNode.class, name = "unnest"),
        @JsonSubTypes.Type(value = ExchangeNode.class, name = "exchange"),
        @JsonSubTypes.Type(value = UnionNode.class, name = "union"),
        @JsonSubTypes.Type(value = IntersectNode.class, name = "intersect"),
        @JsonSubTypes.Type(value = EnforceSingleRowNode.class, name = "scalar"),
        @JsonSubTypes.Type(value = GroupIdNode.class, name = "groupid"),
        @JsonSubTypes.Type(value = ExplainAnalyzeNode.class, name = "explainAnalyze"),
        @JsonSubTypes.Type(value = ApplyNode.class, name = "apply"),
        @JsonSubTypes.Type(value = AssignUniqueId.class, name = "assignUniqueId"),
        @JsonSubTypes.Type(value = LateralJoinNode.class, name = "lateralJoin"),
        @JsonSubTypes.Type(value = StatisticsWriterNode.class, name = "statisticsWriterNode"),
})
public abstract class PlanNode
{
    private final PlanNodeId id;

    protected PlanNode(PlanNodeId id)
    {
        requireNonNull(id, "id is null");
        this.id = id;
    }

    @JsonProperty("id")
    public PlanNodeId getId()
    {
        return id;
    }

    public abstract List<PlanNode> getSources();

    public abstract List<Symbol> getOutputSymbols();

    public abstract PlanNode replaceChildren(List<PlanNode> newChildren);

    public <R, C> R accept(PlanVisitor<R, C> visitor, C context)
    {
        return visitor.visitPlan(this, context);
    }
}

@@ -707,62 +707,8 @@
 ty;%0A
-import com.fasterxml.jackson.annotation.JsonSubTypes;%0A
 impo
@@ -757,16 +757,16 @@
 peInfo;%0A
+
 %0Aimport 
@@ -845,25 +845,16 @@
 ypeInfo(
-%0A        
 use = Js
@@ -871,2867 +871,41 @@
 .Id.
-NAME,%0A        include = JsonTypeInfo.As.PROPERTY,%0A        property = %22@type%22)%0A@JsonSubTypes(%7B%0A        @JsonSubTypes.Type(value = OutputNode.class, name = %22output%22),%0A        @JsonSubTypes.Type(value = ProjectNode.class, name = %22project%22),%0A        @JsonSubTypes.Type(value = TableScanNode.class, name = %22tablescan%22),%0A        @JsonSubTypes.Type(value = ValuesNode.class, name = %22values%22),%0A        @JsonSubTypes.Type(value = AggregationNode.class, name = %22aggregation%22),%0A        @JsonSubTypes.Type(value = MarkDistinctNode.class, name = %22markDistinct%22),%0A        @JsonSubTypes.Type(value = FilterNode.class, name = %22filter%22),%0A        @JsonSubTypes.Type(value = WindowNode.class, name = %22window%22),%0A        @JsonSubTypes.Type(value = RowNumberNode.class, name = %22rowNumber%22),%0A        @JsonSubTypes.Type(value = TopNRowNumberNode.class, name = %22topnRowNumber%22),%0A        @JsonSubTypes.Type(value = LimitNode.class, name = %22limit%22),%0A        @JsonSubTypes.Type(value = DistinctLimitNode.class, name = %22distinctlimit%22),%0A        @JsonSubTypes.Type(value = TopNNode.class, name = %22topn%22),%0A        @JsonSubTypes.Type(value = SampleNode.class, name = %22sample%22),%0A        @JsonSubTypes.Type(value = SortNode.class, name = %22sort%22),%0A        @JsonSubTypes.Type(value = RemoteSourceNode.class, name = %22remoteSource%22),%0A        @JsonSubTypes.Type(value = JoinNode.class, name = %22join%22),%0A        @JsonSubTypes.Type(value = SemiJoinNode.class, name = %22semijoin%22),%0A        @JsonSubTypes.Type(value = SpatialJoinNode.class, name = %22spatialjoin%22),%0A        @JsonSubTypes.Type(value = IndexJoinNode.class, name = %22indexjoin%22),%0A        @JsonSubTypes.Type(value = IndexSourceNode.class, name = %22indexsource%22),%0A        @JsonSubTypes.Type(value = TableWriterNode.class, name = %22tablewriter%22),%0A        @JsonSubTypes.Type(value = DeleteNode.class, name = %22delete%22),%0A        @JsonSubTypes.Type(value = MetadataDeleteNode.class, name = %22metadatadelete%22),%0A        @JsonSubTypes.Type(value = TableFinishNode.class, name = %22tablecommit%22),%0A        @JsonSubTypes.Type(value = UnnestNode.class, name = %22unnest%22),%0A        @JsonSubTypes.Type(value = ExchangeNode.class, name = %22exchange%22),%0A        @JsonSubTypes.Type(value = UnionNode.class, name = %22union%22),%0A        @JsonSubTypes.Type(value = IntersectNode.class, name = %22intersect%22),%0A        @JsonSubTypes.Type(value = EnforceSingleRowNode.class, name = %22scalar%22),%0A        @JsonSubTypes.Type(value = GroupIdNode.class, name = %22groupid%22),%0A        @JsonSubTypes.Type(value = ExplainAnalyzeNode.class, name = %22explainAnalyze%22),%0A        @JsonSubTypes.Type(value = ApplyNode.class, name = %22apply%22),%0A        @JsonSubTypes.Type(value = AssignUniqueId.class, name = %22assignUniqueId%22),%0A        @JsonSubTypes.Type(value = LateralJoinNode.class, name = %22lateralJoin%22),%0A        @JsonSubTypes.Type(value = StatisticsWriterNode.class, name = %22statisticsWriterNode%22),%0A%7D
+MINIMAL_CLASS, property = %22@type%22
 )%0Apu

Remove the SubType list from JsonTypeInfo on PlanNode