Java Code Examples for org.apache.calcite.sql2rel.RelFieldTrimmer#trim()
The following examples show how to use
org.apache.calcite.sql2rel.RelFieldTrimmer#trim() .
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: SqlToRelTestBase.java From calcite with Apache License 2.0 | 6 votes |
public void assertConvertsTo( String sql, String plan, boolean trim) { String sql2 = getDiffRepos().expand("sql", sql); RelNode rel = convertSqlToRel(sql2).project(); assertNotNull(rel); assertValid(rel); if (trim) { final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null); final RelFieldTrimmer trimmer = createFieldTrimmer(relBuilder); rel = trimmer.trim(rel); assertNotNull(rel); assertValid(rel); } // NOTE jvs 28-Mar-2006: insert leading newline so // that plans come out nicely stacked instead of first // line immediately after CDATA start String actual = NL + RelOptUtil.toString(rel); diffRepos.assertEquals("plan", plan, actual); }
Example 2
Source File: PrelTransformer.java From dremio-oss with Apache License 2.0 | 5 votes |
public static RelNode trimFields(final RelNode relNode, boolean shouldLog, boolean isRelPlanning) { final Stopwatch w = Stopwatch.createStarted(); final RelFieldTrimmer trimmer = DremioFieldTrimmer.of(relNode.getCluster(), isRelPlanning); final RelNode trimmed = trimmer.trim(relNode); if(shouldLog) { log(PlannerType.HEP, PlannerPhase.FIELD_TRIMMING, trimmed, logger, w); } return trimmed; }
Example 3
Source File: RelOptMaterializations.java From calcite with Apache License 2.0 | 5 votes |
/** * Trim unused fields in relational expressions. */ private static RelNode trimUnusedfields(RelNode relNode) { final List<RelOptTable> relOptTables = RelOptUtil.findAllTables(relNode); RelOptSchema relOptSchema = null; if (relOptTables.size() != 0) { relOptSchema = relOptTables.get(0).getRelOptSchema(); } final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create( relNode.getCluster(), relOptSchema); final RelFieldTrimmer relFieldTrimmer = new RelFieldTrimmer(null, relBuilder); final RelNode rel = relFieldTrimmer.trim(relNode); return rel; }