Java Code Examples for org.apache.calcite.rel.logical.LogicalProject#getRowType()
The following examples show how to use
org.apache.calcite.rel.logical.LogicalProject#getRowType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OLAPProjectRule.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override public RelNode convert(final RelNode rel) { // KYLIN-3281 // OLAPProjectRule can't normal working with projectRel[input=sortRel] final LogicalProject project = (LogicalProject) rel; final RelNode convertChild = convert(project.getInput(), project.getInput().getTraitSet().replace(OLAPRel.CONVENTION)); final RelOptCluster cluster = convertChild.getCluster(); final RelTraitSet traitSet = cluster.traitSet().replace(OLAPRel.CONVENTION) .replaceIfs(RelCollationTraitDef.INSTANCE, new Supplier<List<RelCollation>>() { public List<RelCollation> get() { // CALCITE-88 return RelMdCollation.project(cluster.getMetadataQuery(), convertChild, project.getProjects()); } }); return new OLAPProjectRel(convertChild.getCluster(), traitSet, convertChild, project.getProjects(), project.getRowType()); }
Example 2
Source File: SamzaSqlValidator.java From samza with Apache License 2.0 | 6 votes |
private void validateOutput(RelRoot relRoot, RelSchemaProvider outputRelSchemaProvider) throws SamzaSqlValidatorException { LogicalProject project = (LogicalProject) relRoot.rel; RelRecordType projectRecord = (RelRecordType) project.getRowType(); RelRecordType outputRecord = (RelRecordType) QueryPlanner.getSourceRelSchema(outputRelSchemaProvider, new RelSchemaConverter()); // Handle any DELETE ops. if (projectRecord.getFieldList().stream().anyMatch(f -> f.getName().equalsIgnoreCase(SamzaSqlRelMessage.OP_NAME))) { validateDeleteOp(relRoot); return; } // Get Samza Sql schema along with Calcite schema. The reason is that the Calcite schema does not have a way // to represent optional fields while Samza Sql schema can represent optional fields. This is the reason that // we use SqlSchema in validating output. SqlSchema outputSqlSchema = QueryPlanner.getSourceSqlSchema(outputRelSchemaProvider); validateOutputRecords(outputSqlSchema, outputRecord, projectRecord, outputRelSchemaProvider); LOG.info("Samza Sql Validation finished successfully."); }
Example 3
Source File: OLAPProjectRule.java From kylin with Apache License 2.0 | 6 votes |
@Override public RelNode convert(final RelNode rel) { // KYLIN-3281 // OLAPProjectRule can't normal working with projectRel[input=sortRel] final LogicalProject project = (LogicalProject) rel; final RelNode convertChild = convert(project.getInput(), project.getInput().getTraitSet().replace(OLAPRel.CONVENTION)); final RelOptCluster cluster = convertChild.getCluster(); final RelTraitSet traitSet = cluster.traitSet().replace(OLAPRel.CONVENTION) .replaceIfs(RelCollationTraitDef.INSTANCE, new Supplier<List<RelCollation>>() { public List<RelCollation> get() { // CALCITE-88 return RelMdCollation.project(cluster.getMetadataQuery(), convertChild, project.getProjects()); } }); return new OLAPProjectRel(convertChild.getCluster(), traitSet, convertChild, project.getProjects(), project.getRowType()); }
Example 4
Source File: SolrRules.java From lucene-solr with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; final RelNode converted = convert(project.getInput(), out); final RelTraitSet traitSet = project.getTraitSet().replace(out); return new SolrProject( rel.getCluster(), traitSet, converted, project.getProjects(), project.getRowType()); }
Example 5
Source File: SamzaSqlValidator.java From samza with Apache License 2.0 | 5 votes |
private void validateDeleteOp(RelRoot relRoot) throws SamzaSqlValidatorException { LogicalProject project = (LogicalProject) relRoot.rel; RelRecordType projectRecord = (RelRecordType) project.getRowType(); // In the case of DELETE op, only the key and DELETE op are required. if (projectRecord.getFieldCount() != 2) { throw new SamzaSqlValidatorException(String.format("Only two select query fields are expected for DELETE op." + " But there are %d fields given in the query.", projectRecord.getFieldCount())); } RelDataTypeField keyField = projectRecord.getField(SamzaSqlRelMessage.KEY_NAME, true, true); if (keyField == null) { throw new SamzaSqlValidatorException(String.format("Select query needs to specify '%s' field while using DELETE" + " op. Eg: 'SELECT myKey AS %s, '%s' AS %s FROM myTable'", SamzaSqlRelMessage.KEY_NAME, SamzaSqlRelMessage.KEY_NAME, SamzaSqlRelMessage.DELETE_OP, SamzaSqlRelMessage.OP_NAME)); } int keyIdx = projectRecord.getFieldList().indexOf(keyField); // Get the node corresponding to the special op. RexNode node = project.getProjects().get(1 - keyIdx); if (!node.toString().equals(String.format("'%s'", SamzaSqlRelMessage.DELETE_OP))) { throw new SamzaSqlValidatorException(String.format("%s op is not supported. Please note that only '%s' op is" + " currently supported. Eg:'SELECT myKey AS %s, '%s' AS %s FROM myStream'", node.toString(), SamzaSqlRelMessage.DELETE_OP, SamzaSqlRelMessage.KEY_NAME, SamzaSqlRelMessage.DELETE_OP, SamzaSqlRelMessage.OP_NAME)); } }
Example 6
Source File: GeodeRules.java From calcite with Apache License 2.0 | 5 votes |
@Override public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; final RelTraitSet traitSet = project.getTraitSet().replace(out); return new GeodeProject( project.getCluster(), traitSet, convert(project.getInput(), out), project.getProjects(), project.getRowType()); }
Example 7
Source File: CassandraRules.java From calcite with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; final RelTraitSet traitSet = project.getTraitSet().replace(out); return new CassandraProject(project.getCluster(), traitSet, convert(project.getInput(), out), project.getProjects(), project.getRowType()); }
Example 8
Source File: MongoRules.java From calcite with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; final RelTraitSet traitSet = project.getTraitSet().replace(out); return new MongoProject(project.getCluster(), traitSet, convert(project.getInput(), out), project.getProjects(), project.getRowType()); }
Example 9
Source File: Bindables.java From calcite with Apache License 2.0 | 5 votes |
public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; return new BindableProject(rel.getCluster(), rel.getTraitSet().replace(BindableConvention.INSTANCE), convert(project.getInput(), project.getInput().getTraitSet() .replace(BindableConvention.INSTANCE)), project.getProjects(), project.getRowType()); }
Example 10
Source File: ElasticsearchProjectRule.java From dk-fitting with Apache License 2.0 | 4 votes |
@Override public RelNode convert(RelNode relNode) { final LogicalProject project = (LogicalProject) relNode; final RelTraitSet traitSet = project.getTraitSet().replace(getOutTrait()); return new ElasticsearchProject(project.getCluster(), traitSet, convert(project.getInput(), getOutTrait()), project.getProjects(), project.getRowType()); }
Example 11
Source File: ElasticsearchProjectRule.java From dk-fitting with Apache License 2.0 | 4 votes |
@Override public RelNode convert(RelNode relNode) { final LogicalProject project = (LogicalProject) relNode; final RelTraitSet traitSet = project.getTraitSet().replace(getOutTrait()); return new ElasticsearchProject(project.getCluster(), traitSet, convert(project.getInput(), getOutTrait()), project.getProjects(), project.getRowType()); }
Example 12
Source File: PigRules.java From calcite with Apache License 2.0 | 4 votes |
public RelNode convert(RelNode rel) { final LogicalProject project = (LogicalProject) rel; final RelTraitSet traitSet = project.getTraitSet().replace(PigRel.CONVENTION); return new PigProject(project.getCluster(), traitSet, project.getInput(), project.getProjects(), project.getRowType()); }
Example 13
Source File: ElasticsearchRules.java From calcite with Apache License 2.0 | 4 votes |
@Override public RelNode convert(RelNode relNode) { final LogicalProject project = (LogicalProject) relNode; final RelTraitSet traitSet = project.getTraitSet().replace(out); return new ElasticsearchProject(project.getCluster(), traitSet, convert(project.getInput(), out), project.getProjects(), project.getRowType()); }