Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets licenses this file
* to you 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 io.druid.sql.calcite.rel;
import io.druid.java.util.common.guava.Sequence;
import io.druid.java.util.common.guava.Sequences;
import io.druid.query.QueryDataSource;
import io.druid.query.filter.DimFilter;
import io.druid.sql.calcite.table.RowSignature;
import org.apache.calcite.interpreter.BindableConvention;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelOptCost;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.RelWriter;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.rel.type.RelDataType;
import java.util.List;
public class DruidNestedGroupBy extends DruidRel
{
private final DruidRel sourceRel;
private final DruidQueryBuilder queryBuilder;
private DruidNestedGroupBy(
RelOptCluster cluster,
RelTraitSet traitSet,
DruidRel sourceRel,
DruidQueryBuilder queryBuilder
)
{
super(cluster, traitSet, sourceRel.getQueryMaker());
this.sourceRel = sourceRel;
this.queryBuilder = queryBuilder;
if (sourceRel.getQueryBuilder().getGrouping() == null) {
throw new IllegalArgumentException("inner query must be groupBy");
}
if (queryBuilder.getGrouping() == null) {
throw new IllegalArgumentException("outer query must be groupBy");
}
}
public static DruidNestedGroupBy from(
final DruidRel sourceRel,
final DimFilter filter,
final Grouping grouping,
final RelDataType rowType,
final List rowOrder
)
{
return new DruidNestedGroupBy(
sourceRel.getCluster(),
sourceRel.getTraitSet(),
sourceRel,
DruidQueryBuilder.fullScan(
sourceRel.getOutputRowSignature(),
sourceRel.getCluster().getTypeFactory()
).withFilter(filter).withGrouping(grouping, rowType, rowOrder)
);
}
@Override
public RowSignature getSourceRowSignature()
{
return sourceRel.getOutputRowSignature();
}
@Override
public DruidQueryBuilder getQueryBuilder()
{
return queryBuilder;
}
@Override
public Sequence