本文整理了Java中org.apache.calcite.rel.core.Project.getRowType()
方法的一些代码示例,展示了Project.getRowType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getRowType()
方法的具体详情如下:
包路径:org.apache.calcite.rel.core.Project
类名称:Project
方法名:getRowType
暂无
代码示例来源:origin: apache/incubator-druid
@Nullable
private SortProject computeSortProject(
PartialDruidQuery partialQuery,
PlannerContext plannerContext,
RowSignature sortingInputRowSignature
)
{
final Project sortProject = partialQuery.getSortProject();
if (sortProject == null) {
return null;
} else {
final ProjectRowOrderAndPostAggregations projectRowOrderAndPostAggregations = computePostAggregations(
plannerContext,
sortingInputRowSignature,
sortProject,
"s"
);
return new SortProject(
sortingInputRowSignature,
projectRowOrderAndPostAggregations.postAggregations,
RowSignature.from(projectRowOrderAndPostAggregations.rowOrder, sortProject.getRowType())
);
}
}
代码示例来源:origin: apache/hive
Schema(Project select, String alias) {
for (RelDataTypeField field : select.getRowType().getFieldList()) {
add(new ColumnInfo(alias, field.getName()));
}
}
代码示例来源:origin: apache/drill
Schema(Project select, String alias) {
for (RelDataTypeField field : select.getRowType().getFieldList()) {
add(new ColumnInfo(alias, field.getName()));
}
}
代码示例来源:origin: apache/incubator-druid
return new SelectProjection(directColumns, virtualColumns, RowSignature.from(rowOrder, project.getRowType()));
代码示例来源:origin: apache/hive
/**
* Assumption:<br>
* 1. Project will always be child of Sort.<br>
* 2. In Calcite every projection in Project is uniquely named
* (unambigous) without using table qualifier (table name).<br>
*
* @param order
* Hive Sort Node
* @return Schema
*/
public Schema(HiveSortLimit order) {
Project select = (Project) order.getInput();
for (String projName : select.getRowType().getFieldNames()) {
add(new ColumnInfo(null, projName));
}
}
代码示例来源:origin: apache/hive
@Override
public RelOptMaterialization apply(RelOptMaterialization materialization) {
final RelNode viewScan = materialization.tableRel;
final RelNode newViewScan;
if (viewScan instanceof Project) {
// There is a Project on top (due to nullability)
final Project pq = (Project) viewScan;
newViewScan = HiveProject.create(optCluster, copyNodeScan(pq.getInput()),
pq.getChildExps(), pq.getRowType(), Collections.<RelCollation> emptyList());
} else {
newViewScan = copyNodeScan(viewScan);
}
return new RelOptMaterialization(newViewScan, materialization.queryRel, null,
materialization.qualifiedTableName);
}
代码示例来源:origin: apache/drill
/**
* Assumption:<br>
* 1. Project will always be child of Sort.<br>
* 2. In Calcite every projection in Project is uniquely named
* (unambigous) without using table qualifier (table name).<br>
*
* @param order
* Hive Sort Node
* @return Schema
*/
public Schema(HiveSortLimit order) {
Project select = (Project) order.getInput();
for (String projName : select.getRowType().getFieldNames()) {
add(new ColumnInfo(null, projName));
}
}
代码示例来源:origin: apache/incubator-druid
aggregations,
havingFilter,
RowSignature.from(projectRowOrderAndPostAggregations.rowOrder, aggregateProject.getRowType())
);
代码示例来源:origin: apache/hive
@Override
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
boolean changed = false;
final RexBuilder rexBuilder = project.getCluster().getRexBuilder();
List<RexNode> newProjects = new ArrayList<>();
for (RexNode oldNode : project.getProjects()) {
RexNode newNode = analyzeRexNode(rexBuilder, oldNode);
if (!newNode.toString().equals(oldNode.toString())) {
changed = true;
newProjects.add(newNode);
} else {
newProjects.add(oldNode);
}
}
if (!changed) {
return;
}
Project newProject = project.copy(project.getTraitSet(), project.getInput(), newProjects,
project.getRowType(), project.getFlags());
call.transformTo(newProject);
}
代码示例来源:origin: apache/storm
@Override
public RelNode convert(RelNode rel) {
final Project project = (Project) rel;
final RelNode input = project.getInput();
return new StreamsProjectRel(project.getCluster(),
project.getTraitSet().replace(StreamsLogicalConvention.INSTANCE),
convert(input, input.getTraitSet().replace(StreamsLogicalConvention.INSTANCE)), project.getProjects(),
project.getRowType());
}
}
代码示例来源:origin: apache/hive
public Result translate(Project e) {
// This variant is for the top project as we want to keep
// the column aliases instead of producing STAR
Result x = visitChild(0, e.getInput());
parseCorrelTable(e, x);
final Builder builder =
x.builder(e, Clause.SELECT);
final List<SqlNode> selectList = new ArrayList<>();
for (RexNode ref : e.getChildExps()) {
SqlNode sqlExpr = builder.context.toSql(null, ref);
addSelect(selectList, sqlExpr, e.getRowType());
}
builder.setSelect(new SqlNodeList(selectList, POS));
return builder.result();
}
代码示例来源:origin: apache/incubator-druid
relBuilder.project(
newProjectRexNodes,
newSelectProject.getRowType().getFieldNames()
);
theProject = (Project) relBuilder.build();
代码示例来源:origin: apache/hive
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
final Filter filter = call.rel(1);
final RelBuilder builder = call.builder();
List<RexNode> projects = project.getChildExps();
List<RexNode> newProjects = rewriteProjects(projects, filter.getCondition(), builder);
if (newProjects == null) {
return;
}
RelNode newProjRel = builder.push(filter)
.project(newProjects, project.getRowType().getFieldNames()).build();
call.transformTo(newProjRel);
}
代码示例来源:origin: apache/drill
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
final Filter filter = call.rel(1);
final RelBuilder builder = call.builder();
List<RexNode> projects = project.getChildExps();
List<RexNode> newProjects = rewriteProjects(projects, filter.getCondition(), builder);
if (newProjects == null) {
return;
}
RelNode newProjRel = builder.push(filter)
.project(newProjects, project.getRowType().getFieldNames()).build();
call.transformTo(newProjRel);
}
代码示例来源:origin: apache/hive
private static RelNode getNewProject(RexNode filterCondToPushBelowProj, RexNode unPushedFilCondAboveProj, Project oldProj,
RelDataTypeFactory typeFactory, RelBuilder relBuilder) {
// convert the filter to one that references the child of the project
RexNode newPushedCondition = RelOptUtil.pushPastProject(filterCondToPushBelowProj, oldProj);
// Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
// nullable and not-nullable conditions, but a CAST might get in the way of
// other rewrites.
if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
newPushedCondition = ((RexCall) newPushedCondition).getOperands().get(0);
}
RelNode newPushedFilterRel = relBuilder.push(oldProj.getInput()).filter(newPushedCondition).build();
RelNode newProjRel = relBuilder.push(newPushedFilterRel)
.project(oldProj.getProjects(), oldProj.getRowType().getFieldNames()).build();
if (unPushedFilCondAboveProj != null) {
// Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
// nullable and not-nullable conditions, but a CAST might get in the way of
// other rewrites.
if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
unPushedFilCondAboveProj = ((RexCall) unPushedFilCondAboveProj).getOperands().get(0);
}
newProjRel = relBuilder.push(newProjRel).filter(unPushedFilCondAboveProj).build();
}
return newProjRel;
}
代码示例来源:origin: apache/hive
if (project.getRowType().getFieldCount() == 0) {
input = project.getInput();
代码示例来源:origin: apache/drill
public void onMatch(RelOptRuleCall call) {
final Filter filter = call.rel(0);
final Project project = call.rel(1);
final List<RexNode> newProjects = new ArrayList<>(project.getProjects());
newProjects.add(filter.getCondition());
final RelOptCluster cluster = filter.getCluster();
RelDataType newRowType =
cluster.getTypeFactory().builder()
.addAll(project.getRowType().getFieldList())
.add("condition", Util.last(newProjects).getType())
.build();
final RelNode newProject =
project.copy(project.getTraitSet(),
project.getInput(),
newProjects,
newRowType);
final RexInputRef newCondition =
cluster.getRexBuilder().makeInputRef(newProject,
newProjects.size() - 1);
call.transformTo(filter.copy(filter.getTraitSet(), newProject, newCondition));
}
}
代码示例来源:origin: apache/drill
private static RelNode getNewProject(RexNode filterCondToPushBelowProj, RexNode unPushedFilCondAboveProj, Project oldProj,
RelDataTypeFactory typeFactory, RelBuilder relBuilder) {
// convert the filter to one that references the child of the project
RexNode newPushedCondition = RelOptUtil.pushPastProject(filterCondToPushBelowProj, oldProj);
// Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
// nullable and not-nullable conditions, but a CAST might get in the way of
// other rewrites.
if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
newPushedCondition = ((RexCall) newPushedCondition).getOperands().get(0);
}
RelNode newPushedFilterRel = relBuilder.push(oldProj.getInput()).filter(newPushedCondition).build();
RelNode newProjRel = relBuilder.push(newPushedFilterRel)
.project(oldProj.getProjects(), oldProj.getRowType().getFieldNames()).build();
if (unPushedFilCondAboveProj != null) {
// Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
// nullable and not-nullable conditions, but a CAST might get in the way of
// other rewrites.
if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
unPushedFilCondAboveProj = ((RexCall) unPushedFilCondAboveProj).getOperands().get(0);
}
newProjRel = relBuilder.push(newProjRel).filter(unPushedFilCondAboveProj).build();
}
return newProjRel;
}
代码示例来源:origin: apache/drill
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
//TODO: replace HiveSubQRemoveRelBuilder with calcite's once calcite 1.11.0 is released
final HiveSubQRemoveRelBuilder builder = new HiveSubQRemoveRelBuilder(null, call.rel(0).getCluster(), null);
final RexSubQuery e =
RexUtil.SubQueryFinder.find(project.getProjects());
assert e != null;
final RelOptUtil.Logic logic =
LogicVisitor.find(RelOptUtil.Logic.TRUE_FALSE_UNKNOWN,
project.getProjects(), e);
builder.push(project.getInput());
final int fieldCount = builder.peek().getRowType().getFieldCount();
final RexNode target = apply(e, HiveFilter.getVariablesSet(e),
logic, builder, 1, fieldCount, false);
final RexShuttle shuttle = new ReplaceSubQueryShuttle(e, target);
builder.project(shuttle.apply(project.getProjects()),
project.getRowType().getFieldNames());
call.transformTo(builder.build());
}
};
代码示例来源:origin: apache/incubator-druid
.project(project.getProjects(), project.getRowType().getFieldNames())
.build()
);
内容来源于网络,如有侵权,请联系作者删除!