blob: 26f9fa20efe14f587c5a3ec0d370fa452f802d3d [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Generated by javadoc (17) -->
<title>MaterializedViewRule (Apache Calcite API)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="declaration: package: org.apache.calcite.rel.rules.materialize, class: MaterializedViewRule">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../script-dir/jquery-ui.min.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../jquery-ui.overrides.css" title="Style">
<script type="text/javascript" src="../../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../../script-dir/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="../../../../../../script-dir/jquery-ui.min.js"></script>
</head>
<body class="class-declaration-page">
<script type="text/javascript">var evenRowColor = "even-row-color";
var oddRowColor = "odd-row-color";
var tableTab = "table-tab";
var activeTableTab = "active-table-tab";
var pathtoroot = "../../../../../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flex-box">
<header role="banner" class="flex-header">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="top-nav" id="navbar-top">
<div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div>
<div class="about-language"><b>Apache Calcite</b></div>
<ul id="navbar-top-firstrow" class="nav-list" title="Navigation">
<li><a href="../../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="nav-bar-cell1-rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html#class">Help</a></li>
</ul>
</div>
<div class="sub-nav">
<div>
<ul class="sub-nav-list">
<li>Summary:&nbsp;</li>
<li><a href="#nested-class-summary">Nested</a>&nbsp;|&nbsp;</li>
<li><a href="#field-summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method-summary">Method</a></li>
</ul>
<ul class="sub-nav-list">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method-detail">Method</a></li>
</ul>
</div>
<div class="nav-list-search"><label for="search-input">SEARCH:</label>
<input type="text" id="search-input" value="search" disabled="disabled">
<input type="reset" id="reset-button" value="reset" disabled="disabled">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<span class="skip-nav" id="skip-navbar-top"></span></nav>
</header>
<div class="flex-content">
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="sub-title"><span class="package-label-in-type">Package</span>&nbsp;<a href="package-summary.html">org.apache.calcite.rel.rules.materialize</a></div>
<h1 title="Class MaterializedViewRule" class="title">Class MaterializedViewRule&lt;C extends <a href="MaterializedViewRule.Config.html" title="interface in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.Config</a>&gt;</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">java.lang.Object</a>
<div class="inheritance"><a href="../../../plan/RelOptRule.html" title="class in org.apache.calcite.plan">org.apache.calcite.plan.RelOptRule</a>
<div class="inheritance"><a href="../../../plan/RelRule.html" title="class in org.apache.calcite.plan">org.apache.calcite.plan.RelRule</a>&lt;C&gt;
<div class="inheritance">org.apache.calcite.rel.rules.materialize.MaterializedViewRule&lt;C&gt;</div>
</div>
</div>
</div>
<section class="class-description" id="class-description">
<dl class="notes">
<dt>Type Parameters:</dt>
<dd><code>C</code> - Configuration type</dd>
</dl>
<dl class="notes">
<dt>Direct Known Subclasses:</dt>
<dd><code><a href="MaterializedViewAggregateRule.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewAggregateRule</a></code>, <code><a href="MaterializedViewJoinRule.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewJoinRule</a></code></dd>
</dl>
<hr>
<div class="type-signature"><span class="modifiers">public abstract class </span><span class="element-name type-name-label">MaterializedViewRule&lt;C extends <a href="MaterializedViewRule.Config.html" title="interface in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.Config</a>&gt;</span>
<span class="extends-implements">extends <a href="../../../plan/RelRule.html" title="class in org.apache.calcite.plan">RelRule</a>&lt;C&gt;</span></div>
<div class="block">Planner rule that converts a <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core"><code>Project</code></a>
followed by <a href="../../core/Aggregate.html" title="class in org.apache.calcite.rel.core"><code>Aggregate</code></a> or an
<a href="../../core/Aggregate.html" title="class in org.apache.calcite.rel.core"><code>Aggregate</code></a> to a scan (and possibly
other operations) over a materialized view.</div>
</section>
<section class="summary">
<ul class="summary-list">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<li>
<section class="nested-class-summary" id="nested-class-summary">
<h2>Nested Class Summary</h2>
<div class="caption"><span>Nested Classes</span></div>
<div class="summary-table three-column-summary">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Class</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color"><code>static interface&nbsp;</code></div>
<div class="col-second even-row-color"><code><a href="MaterializedViewRule.Config.html" class="type-name-link" title="interface in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.Config</a></code></div>
<div class="col-last even-row-color">
<div class="block">Rule configuration.</div>
</div>
<div class="col-first odd-row-color"><code>protected static class&nbsp;</code></div>
<div class="col-second odd-row-color"><code><a href="MaterializedViewRule.Edge.html" class="type-name-link" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.Edge</a></code></div>
<div class="col-last odd-row-color">
<div class="block">Edge for graph.</div>
</div>
<div class="col-first even-row-color"><code>protected static class&nbsp;</code></div>
<div class="col-second even-row-color"><code><a href="MaterializedViewRule.EquivalenceClasses.html" class="type-name-link" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a></code></div>
<div class="col-last even-row-color">
<div class="block">Class representing an equivalence class, i.e., a set of equivalent columns</div>
</div>
<div class="col-first odd-row-color"><code>protected static enum&nbsp;</code></div>
<div class="col-second odd-row-color"><code><a href="MaterializedViewRule.MatchModality.html" class="type-name-link" title="enum in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.MatchModality</a></code></div>
<div class="col-last odd-row-color">
<div class="block">Complete, view partial, or query partial.</div>
</div>
<div class="col-first even-row-color"><code>protected static class&nbsp;</code></div>
<div class="col-second even-row-color"><code><a href="MaterializedViewRule.NodeLineage.html" class="type-name-link" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.NodeLineage</a></code></div>
<div class="col-last even-row-color">
<div class="block">Expression lineage details.</div>
</div>
<div class="col-first odd-row-color"><code>protected static class&nbsp;</code></div>
<div class="col-second odd-row-color"><code><a href="MaterializedViewRule.ViewPartialRewriting.html" class="type-name-link" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.ViewPartialRewriting</a></code></div>
<div class="col-last odd-row-color">
<div class="block">View partitioning result.</div>
</div>
</div>
<div class="inherited-list">
<h2 id="nested-classes-inherited-from-class-org.apache.calcite.plan.RelRule">Nested classes/interfaces inherited from class&nbsp;org.apache.calcite.plan.<a href="../../../plan/RelRule.html" title="class in org.apache.calcite.plan">RelRule</a></h2>
<code><a href="../../../plan/RelRule.Done.html" title="interface in org.apache.calcite.plan">RelRule.Done</a>, <a href="../../../plan/RelRule.MatchHandler.html" title="interface in org.apache.calcite.plan">RelRule.MatchHandler</a>&lt;<a href="../../../plan/RelRule.MatchHandler.html" title="type parameter in RelRule.MatchHandler">R</a> extends <a href="../../../plan/RelOptRule.html" title="class in org.apache.calcite.plan">RelOptRule</a>&gt;, <a href="../../../plan/RelRule.OperandBuilder.html" title="interface in org.apache.calcite.plan">RelRule.OperandBuilder</a>, <a href="../../../plan/RelRule.OperandDetailBuilder.html" title="interface in org.apache.calcite.plan">RelRule.OperandDetailBuilder</a>&lt;<a href="../../../plan/RelRule.OperandDetailBuilder.html" title="type parameter in RelRule.OperandDetailBuilder">R</a> extends <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&gt;, <a href="../../../plan/RelRule.OperandTransform.html" title="interface in org.apache.calcite.plan">RelRule.OperandTransform</a></code></div>
<div class="inherited-list">
<h2 id="nested-classes-inherited-from-class-org.apache.calcite.plan.RelOptRule">Nested classes/interfaces inherited from class&nbsp;org.apache.calcite.plan.<a href="../../../plan/RelOptRule.html" title="class in org.apache.calcite.plan">RelOptRule</a></h2>
<code><a href="../../../plan/RelOptRule.ConverterRelOptRuleOperand.html" title="class in org.apache.calcite.plan">RelOptRule.ConverterRelOptRuleOperand</a></code></div>
</section>
</li>
<!-- =========== FIELD SUMMARY =========== -->
<li>
<section class="field-summary" id="field-summary">
<h2>Field Summary</h2>
<div class="inherited-list">
<h3 id="fields-inherited-from-class-org.apache.calcite.plan.RelRule">Fields inherited from class&nbsp;org.apache.calcite.plan.<a href="../../../plan/RelRule.html" title="class in org.apache.calcite.plan">RelRule</a></h3>
<code><a href="../../../plan/RelRule.html#config">config</a></code></div>
<div class="inherited-list">
<h3 id="fields-inherited-from-class-org.apache.calcite.plan.RelOptRule">Fields inherited from class&nbsp;org.apache.calcite.plan.<a href="../../../plan/RelOptRule.html" title="class in org.apache.calcite.plan">RelOptRule</a></h3>
<code><a href="../../../plan/RelOptRule.html#description">description</a>, <a href="../../../plan/RelOptRule.html#operands">operands</a>, <a href="../../../plan/RelOptRule.html#relBuilderFactory">relBuilderFactory</a></code></div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li>
<section class="method-summary" id="method-summary">
<h2>Method Summary</h2>
<div id="method-summary-table">
<div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab3" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab3', 3)" class="table-tab">Abstract Methods</button><button id="method-summary-table-tab4" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" class="table-tab">Concrete Methods</button></div>
<div id="method-summary-table.tabpanel" role="tabpanel">
<div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected boolean</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#compensatePartial(java.util.Set,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,java.util.Set,com.google.common.collect.Multimap)" class="member-name-link">compensatePartial</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;sourceTableRefs,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;sourceEC,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;targetTableRefs,
@Nullable com.google.common.collect.Multimap&lt;<a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex">RexTableInputRef</a>,<wbr><a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex">RexTableInputRef</a>&gt;&nbsp;compensationEquiColumns)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">It checks whether the target can be rewritten using the source even though the
source uses additional tables.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>protected abstract @Nullable <a href="MaterializedViewRule.ViewPartialRewriting.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.ViewPartialRewriting</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#compensateViewPartial(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,java.util.Set,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,java.util.Set)" class="member-name-link">compensateViewPartial</a><wbr>(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;relBuilder,
<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;input,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;queryTableRefs,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;queryEC,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topViewProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;viewNode,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;viewTableRefs)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">It checks whether the query can be rewritten using the view even though the
query uses additional tables.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected @Nullable <a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#computeCompensationPredicates(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexSimplify,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.util.Pair,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.util.Pair,com.google.common.collect.BiMap)" class="member-name-link">computeCompensationPredicates</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexSimplify.html" title="class in org.apache.calcite.rex">RexSimplify</a>&nbsp;simplify,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;sourceEC,
<a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;sourcePreds,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;targetEC,
<a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;targetPreds,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;sourceToTargetTableMapping)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">We check whether the predicates in the source are contained in the predicates
in the target.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>protected abstract @Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#createUnion(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode)" class="member-name-link">createUnion</a><wbr>(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;relBuilder,
<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;unionInputQuery,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;unionInputView)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">If the view will be used in a union rewriting, this method is responsible for
generating the union and any other operator needed on top of it, e.g., a Project
operator.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected @Nullable com.google.common.collect.Multimap&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#extractPossibleMapping(java.util.List,java.util.List)" class="member-name-link">extractPossibleMapping</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex">RexTableInputRef</a>&gt;&gt;&nbsp;sourceEquivalenceClasses,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex">RexTableInputRef</a>&gt;&gt;&nbsp;targetEquivalenceClasses)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Given the source and target equivalence classes, it extracts the possible mappings
from each source equivalence class to each target equivalence class.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#extractReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.RelNode)" class="member-name-link">extractReferences</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">If the node is an Aggregate, it returns a list of references to the grouping columns.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected @Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#generateEquivalenceClasses(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses)" class="member-name-link">generateEquivalenceClasses</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;sourceEC,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;targetEC)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Given the equi-column predicates of the source and the target and the
computed equivalence classes, it extracts possible mappings between
the equivalence classes.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected <a href="MaterializedViewRule.NodeLineage.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.NodeLineage</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#generateSwapColumnTableReferencesLineage(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,java.util.List)" class="member-name-link">generateSwapColumnTableReferencesLineage</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;tableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;ec,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;nodeExprs)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">It swaps the column references and then the table references of the input
expressions using the equivalence classes and the table mapping.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected <a href="MaterializedViewRule.NodeLineage.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.NodeLineage</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#generateSwapTableColumnReferencesLineage(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,java.util.List)" class="member-name-link">generateSwapTableColumnReferencesLineage</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;tableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;ec,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;nodeExprs)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">It swaps the table references and then the column references of the input
expressions using the table mapping and the equivalence classes.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#generateTableMappings(com.google.common.collect.Multimap)" class="member-name-link">generateTableMappings</a><wbr>(com.google.common.collect.Multimap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;multiMapTables)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">It will flatten a multimap containing table references to table references,
producing all possible combinations of mappings.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>protected abstract boolean</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#isValidPlan(org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery)" class="member-name-link">isValidPlan</a><wbr>(@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected boolean</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#isValidRelNodePlan(org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery)" class="member-name-link">isValidRelNodePlan</a><wbr>(<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Returns whether a RelNode is a valid tree.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>boolean</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#matches(org.apache.calcite.plan.RelOptRuleCall)" class="member-name-link">matches</a><wbr>(<a href="../../../plan/RelOptRuleCall.html" title="class in org.apache.calcite.plan">RelOptRuleCall</a>&nbsp;call)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Returns whether this rule could possibly match the given operands.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#perform(org.apache.calcite.plan.RelOptRuleCall,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode)" class="member-name-link">perform</a><wbr>(<a href="../../../plan/RelOptRuleCall.html" title="class in org.apache.calcite.plan">RelOptRuleCall</a>&nbsp;call,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Rewriting logic is based on "Optimizing Queries Using Materialized Views:
A Practical, Scalable Solution" by Goldstein and Larson.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>protected abstract <a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>,<wbr><a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#pushFilterToOriginalViewPlan(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode,org.apache.calcite.rex.RexNode)" class="member-name-link">pushFilterToOriginalViewPlan</a><wbr>(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;builder,
@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;topViewProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;viewNode,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;cond)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Once we create a compensation predicate, this method is responsible for pushing
the resulting filter through the view nodes.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#replaceWithOriginalReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.NodeLineage,org.apache.calcite.rex.RexNode)" class="member-name-link">replaceWithOriginalReferences</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="MaterializedViewRule.NodeLineage.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.NodeLineage</a>&nbsp;nodeLineage,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;exprToRewrite)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Given the input expression, it will replace (sub)expressions when possible
using the content of the mapping.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected @Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#rewriteExpression(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode,java.util.List,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,boolean,org.apache.calcite.rex.RexNode)" class="member-name-link">rewriteExpression</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;targetNode,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;nodeExprs,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;tableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;ec,
boolean&nbsp;swapTableColumn,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;exprToRewrite)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">First, the method takes the node expressions <code>nodeExprs</code> and swaps the table
and column references using the table mapping and the equivalence classes.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected @Nullable <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#rewriteExpressions(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode,java.util.List,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,boolean,java.util.List)" class="member-name-link">rewriteExpressions</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;targetNode,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;nodeExprs,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;tableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;ec,
boolean&nbsp;swapTableColumn,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;exprsToRewrite)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">First, the method takes the node expressions <code>nodeExprs</code> and swaps the table
and column references using the table mapping and the equivalence classes.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>protected abstract @Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#rewriteQuery(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexSimplify,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rex.RexNode,org.apache.calcite.rex.RexNode,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses)" class="member-name-link">rewriteQuery</a><wbr>(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;relBuilder,
<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexSimplify.html" title="class in org.apache.calcite.rex">RexSimplify</a>&nbsp;simplify,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;compensationColumnsEquiPred,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;otherCompensationPred,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;viewToQueryTableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;viewEC,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;queryEC)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">If the view will be used in a union rewriting, this method is responsible for
rewriting the query branch of the union using the given compensation predicate.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>protected abstract @Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#rewriteView(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexSimplify,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.MatchModality,boolean,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses)" class="member-name-link">rewriteView</a><wbr>(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;relBuilder,
<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexSimplify.html" title="class in org.apache.calcite.rex">RexSimplify</a>&nbsp;simplify,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="MaterializedViewRule.MatchModality.html" title="enum in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.MatchModality</a>&nbsp;matchModality,
boolean&nbsp;unionRewriting,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;input,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topViewProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;viewNode,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;queryToViewTableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;queryEC)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Rewrites the query using the given view query.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected @Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#shuttleReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexNode,com.google.common.collect.Multimap)" class="member-name-link">shuttleReferences</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;expr,
com.google.common.collect.Multimap&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>&gt;&nbsp;exprsLineage)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Replaces all the possible sub-expressions by input references
to the input node.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected @Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#shuttleReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexNode,com.google.common.collect.Multimap,org.apache.calcite.rel.RelNode,com.google.common.collect.Multimap)" class="member-name-link">shuttleReferences</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;expr,
com.google.common.collect.Multimap&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>&gt;&nbsp;exprsLineage,
@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
@Nullable com.google.common.collect.Multimap&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>&gt;&nbsp;rewritingMapping)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Replaces all the possible sub-expressions by input references
to the input node.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected @Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#shuttleReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexNode,org.apache.calcite.util.mapping.Mapping)" class="member-name-link">shuttleReferences</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;node,
<a href="../../../util/mapping/Mapping.html" title="interface in org.apache.calcite.util.mapping">Mapping</a>&nbsp;mapping)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Replaces all the input references by the position in the
input column set.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>protected <a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#splitPredicates(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexNode)" class="member-name-link">splitPredicates</a><wbr>(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;pred)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Classifies each of the predicates in the list into one of these two
categories:
1-l) column equality predicates, or
2-r) residual predicates, all the rest
</div>
</div>
</div>
</div>
</div>
<div class="inherited-list">
<h3 id="methods-inherited-from-class-org.apache.calcite.plan.RelOptRule">Methods inherited from class&nbsp;org.apache.calcite.plan.<a href="../../../plan/RelOptRule.html" title="class in org.apache.calcite.plan">RelOptRule</a></h3>
<code><a href="../../../plan/RelOptRule.html#any()">any</a>, <a href="../../../plan/RelOptRule.html#convert(org.apache.calcite.rel.RelNode,org.apache.calcite.plan.RelTrait)">convert</a>, <a href="../../../plan/RelOptRule.html#convert(org.apache.calcite.rel.RelNode,org.apache.calcite.plan.RelTraitSet)">convert</a>, <a href="../../../plan/RelOptRule.html#convertList(java.util.List,org.apache.calcite.plan.RelTrait)">convertList</a>, <a href="../../../plan/RelOptRule.html#convertOperand(java.lang.Class,com.google.common.base.Predicate,org.apache.calcite.plan.RelTrait)">convertOperand</a>, <a href="../../../plan/RelOptRule.html#convertOperand(java.lang.Class,java.util.function.Predicate,org.apache.calcite.plan.RelTrait)">convertOperand</a>, <a href="../../../plan/RelOptRule.html#equals(java.lang.Object)">equals</a>, <a href="../../../plan/RelOptRule.html#equals(org.apache.calcite.plan.RelOptRule)">equals</a>, <a href="../../../plan/RelOptRule.html#getOperand()">getOperand</a>, <a href="../../../plan/RelOptRule.html#getOperands()">getOperands</a>, <a href="../../../plan/RelOptRule.html#getOutConvention()">getOutConvention</a>, <a href="../../../plan/RelOptRule.html#getOutTrait()">getOutTrait</a>, <a href="../../../plan/RelOptRule.html#hashCode()">hashCode</a>, <a href="../../../plan/RelOptRule.html#none()">none</a>, <a href="../../../plan/RelOptRule.html#onMatch(org.apache.calcite.plan.RelOptRuleCall)">onMatch</a>, <a href="../../../plan/RelOptRule.html#operand(java.lang.Class,org.apache.calcite.plan.RelOptRuleOperandChildren)">operand</a>, <a href="../../../plan/RelOptRule.html#operand(java.lang.Class,org.apache.calcite.plan.RelOptRuleOperand,org.apache.calcite.plan.RelOptRuleOperand...)">operand</a>, <a href="../../../plan/RelOptRule.html#operand(java.lang.Class,org.apache.calcite.plan.RelTrait,com.google.common.base.Predicate,org.apache.calcite.plan.RelOptRuleOperandChildren)">operand</a>, <a href="../../../plan/RelOptRule.html#operand(java.lang.Class,org.apache.calcite.plan.RelTrait,com.google.common.base.Predicate,org.apache.calcite.plan.RelOptRuleOperand,org.apache.calcite.plan.RelOptRuleOperand...)">operand</a>, <a href="../../../plan/RelOptRule.html#operand(java.lang.Class,org.apache.calcite.plan.RelTrait,org.apache.calcite.plan.RelOptRuleOperandChildren)">operand</a>, <a href="../../../plan/RelOptRule.html#operandJ(java.lang.Class,org.apache.calcite.plan.RelTrait,java.util.function.Predicate,org.apache.calcite.plan.RelOptRuleOperandChildren)">operandJ</a>, <a href="../../../plan/RelOptRule.html#operandJ(java.lang.Class,org.apache.calcite.plan.RelTrait,java.util.function.Predicate,org.apache.calcite.plan.RelOptRuleOperand,org.apache.calcite.plan.RelOptRuleOperand...)">operandJ</a>, <a href="../../../plan/RelOptRule.html#some(org.apache.calcite.plan.RelOptRuleOperand,org.apache.calcite.plan.RelOptRuleOperand...)">some</a>, <a href="../../../plan/RelOptRule.html#toString()">toString</a>, <a href="../../../plan/RelOptRule.html#unordered(org.apache.calcite.plan.RelOptRuleOperand,org.apache.calcite.plan.RelOptRuleOperand...)">unordered</a></code></div>
<div class="inherited-list">
<h3 id="methods-inherited-from-class-java.lang.Object">Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></h3>
<code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#clone()" title="class or interface in java.lang" class="external-link">clone</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#finalize()" title="class or interface in java.lang" class="external-link">finalize</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#getClass()" title="class or interface in java.lang" class="external-link">getClass</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notify()" title="class or interface in java.lang" class="external-link">notify</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notifyAll()" title="class or interface in java.lang" class="external-link">notifyAll</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait()" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long)" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="class or interface in java.lang" class="external-link">wait</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="details-list">
<!-- ============ METHOD DETAIL ========== -->
<li>
<section class="method-details" id="method-detail">
<h2>Method Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="matches(org.apache.calcite.plan.RelOptRuleCall)">
<h3>matches</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name">matches</span><wbr><span class="parameters">(<a href="../../../plan/RelOptRuleCall.html" title="class in org.apache.calcite.plan">RelOptRuleCall</a>&nbsp;call)</span></div>
<div class="block"><span class="descfrm-type-label">Description copied from class:&nbsp;<code><a href="../../../plan/RelOptRule.html#matches(org.apache.calcite.plan.RelOptRuleCall)">RelOptRule</a></code></span></div>
<div class="block">Returns whether this rule could possibly match the given operands.
<p>This method is an opportunity to apply side-conditions to a rule. The
<a href="../../../plan/RelOptPlanner.html" title="interface in org.apache.calcite.plan"><code>RelOptPlanner</code></a> calls this method after matching all operands of
the rule, and before calling <a href="../../../plan/RelOptRule.html#onMatch(org.apache.calcite.plan.RelOptRuleCall)"><code>RelOptRule.onMatch(RelOptRuleCall)</code></a>.
<p>In implementations of <a href="../../../plan/RelOptPlanner.html" title="interface in org.apache.calcite.plan"><code>RelOptPlanner</code></a> which may queue up a
matched <a href="../../../plan/RelOptRuleCall.html" title="class in org.apache.calcite.plan"><code>RelOptRuleCall</code></a> for a long time before calling
<a href="../../../plan/RelOptRule.html#onMatch(org.apache.calcite.plan.RelOptRuleCall)"><code>RelOptRule.onMatch(RelOptRuleCall)</code></a>, this method is beneficial because it
allows the planner to discard rules earlier in the process.
<p>The default implementation of this method returns <code>true</code>.
It is acceptable for any implementation of this method to give a false
positives, that is, to say that the rule matches the operands but have
<a href="../../../plan/RelOptRule.html#onMatch(org.apache.calcite.plan.RelOptRuleCall)"><code>RelOptRule.onMatch(RelOptRuleCall)</code></a> subsequently not generate any
successors.
<p>The following script is useful to identify rules which commonly
produce no successors. You should override this method for these rules:
<blockquote>
<pre><code>awk '
/Apply rule/ {rule=$4; ruleCount[rule]++;}
/generated 0 successors/ {ruleMiss[rule]++;}
END {
printf "%-30s %s %s\n", "Rule", "Fire", "Miss";
for (i in ruleCount) {
printf "%-30s %5d %5d\n", i, ruleCount[i], ruleMiss[i];
}
} ' FarragoTrace.log</code></pre>
</blockquote></div>
<dl class="notes">
<dt>Overrides:</dt>
<dd><code><a href="../../../plan/RelOptRule.html#matches(org.apache.calcite.plan.RelOptRuleCall)">matches</a></code>&nbsp;in class&nbsp;<code><a href="../../../plan/RelOptRule.html" title="class in org.apache.calcite.plan">RelOptRule</a></code></dd>
<dt>Parameters:</dt>
<dd><code>call</code> - Rule call which has been determined to match all operands of
this rule</dd>
<dt>Returns:</dt>
<dd>whether this RelOptRule matches a given RelOptRuleCall</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="perform(org.apache.calcite.plan.RelOptRuleCall,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode)">
<h3>perform</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">perform</span><wbr><span class="parameters">(<a href="../../../plan/RelOptRuleCall.html" title="class in org.apache.calcite.plan">RelOptRuleCall</a>&nbsp;call,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node)</span></div>
<div class="block">Rewriting logic is based on "Optimizing Queries Using Materialized Views:
A Practical, Scalable Solution" by Goldstein and Larson.
<p>On the query side, rules matches a Project-node chain or node, where node
is either an Aggregate or a Join. Subplan rooted at the node operator must
be composed of one or more of the following operators: TableScan, Project,
Filter, and Join.
<p>For each join MV, we need to check the following:
<ol>
<li> The plan rooted at the Join operator in the view produces all rows
needed by the plan rooted at the Join operator in the query.</li>
<li> All columns required by compensating predicates, i.e., predicates that
need to be enforced over the view, are available at the view output.</li>
<li> All output expressions can be computed from the output of the view.</li>
<li> All output rows occur with the correct duplication factor. We might
rely on existing Unique-Key - Foreign-Key relationships to extract that
information.</li>
</ol>
<p>In turn, for each aggregate MV, we need to check the following:
<ol>
<li> The plan rooted at the Aggregate operator in the view produces all rows
needed by the plan rooted at the Aggregate operator in the query.</li>
<li> All columns required by compensating predicates, i.e., predicates that
need to be enforced over the view, are available at the view output.</li>
<li> The grouping columns in the query are a subset of the grouping columns
in the view.</li>
<li> All columns required to perform further grouping are available in the
view output.</li>
<li> All columns required to compute output expressions are available in the
view output.</li>
</ol>
<p>The rule contains multiple extensions compared to the original paper. One of
them is the possibility of creating rewritings using Union operators, e.g., if
the result of a query is partially contained in the materialized view.</div>
</section>
</li>
<li>
<section class="detail" id="isValidPlan(org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery)">
<h3>isValidPlan</h3>
<div class="member-signature"><span class="modifiers">protected abstract</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name">isValidPlan</span><wbr><span class="parameters">(@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq)</span></div>
</section>
</li>
<li>
<section class="detail" id="compensateViewPartial(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,java.util.Set,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,java.util.Set)">
<h3>compensateViewPartial</h3>
<div class="member-signature"><span class="modifiers">protected abstract</span>&nbsp;<span class="return-type">@Nullable <a href="MaterializedViewRule.ViewPartialRewriting.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.ViewPartialRewriting</a></span>&nbsp;<span class="element-name">compensateViewPartial</span><wbr><span class="parameters">(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;relBuilder,
<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;input,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;queryTableRefs,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;queryEC,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topViewProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;viewNode,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;viewTableRefs)</span></div>
<div class="block">It checks whether the query can be rewritten using the view even though the
query uses additional tables.
<p>Rules implementing the method should follow different approaches depending on the
operators they rewrite.</div>
<dl class="notes">
<dt>Returns:</dt>
<dd>ViewPartialRewriting, or null if the rewrite can't be done</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="rewriteQuery(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexSimplify,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rex.RexNode,org.apache.calcite.rex.RexNode,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses)">
<h3>rewriteQuery</h3>
<div class="member-signature"><span class="modifiers">protected abstract</span>&nbsp;<span class="return-type">@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a></span>&nbsp;<span class="element-name">rewriteQuery</span><wbr><span class="parameters">(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;relBuilder,
<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexSimplify.html" title="class in org.apache.calcite.rex">RexSimplify</a>&nbsp;simplify,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;compensationColumnsEquiPred,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;otherCompensationPred,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;viewToQueryTableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;viewEC,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;queryEC)</span></div>
<div class="block">If the view will be used in a union rewriting, this method is responsible for
rewriting the query branch of the union using the given compensation predicate.
<p>If a rewriting can be produced, we return that rewriting. If it cannot
be produced, we will return null.</div>
</section>
</li>
<li>
<section class="detail" id="createUnion(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode)">
<h3>createUnion</h3>
<div class="member-signature"><span class="modifiers">protected abstract</span>&nbsp;<span class="return-type">@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a></span>&nbsp;<span class="element-name">createUnion</span><wbr><span class="parameters">(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;relBuilder,
<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;unionInputQuery,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;unionInputView)</span></div>
<div class="block">If the view will be used in a union rewriting, this method is responsible for
generating the union and any other operator needed on top of it, e.g., a Project
operator.</div>
</section>
</li>
<li>
<section class="detail" id="rewriteView(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexSimplify,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.MatchModality,boolean,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.core.Project,org.apache.calcite.rel.RelNode,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses)">
<h3>rewriteView</h3>
<div class="member-signature"><span class="modifiers">protected abstract</span>&nbsp;<span class="return-type">@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a></span>&nbsp;<span class="element-name">rewriteView</span><wbr><span class="parameters">(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;relBuilder,
<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexSimplify.html" title="class in org.apache.calcite.rex">RexSimplify</a>&nbsp;simplify,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="MaterializedViewRule.MatchModality.html" title="enum in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.MatchModality</a>&nbsp;matchModality,
boolean&nbsp;unionRewriting,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;input,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
@Nullable <a href="../../core/Project.html" title="class in org.apache.calcite.rel.core">Project</a>&nbsp;topViewProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;viewNode,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;queryToViewTableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;queryEC)</span></div>
<div class="block">Rewrites the query using the given view query.
<p>The input node is a Scan on the view table and possibly a compensation Filter
on top. If a rewriting can be produced, we return that rewriting. If it cannot
be produced, we will return null.</div>
</section>
</li>
<li>
<section class="detail" id="pushFilterToOriginalViewPlan(org.apache.calcite.tools.RelBuilder,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode,org.apache.calcite.rex.RexNode)">
<h3>pushFilterToOriginalViewPlan</h3>
<div class="member-signature"><span class="modifiers">protected abstract</span>&nbsp;<span class="return-type"><a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>,<wbr><a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&gt;</span>&nbsp;<span class="element-name">pushFilterToOriginalViewPlan</span><wbr><span class="parameters">(<a href="../../../tools/RelBuilder.html" title="class in org.apache.calcite.tools">RelBuilder</a>&nbsp;builder,
@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;topViewProject,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;viewNode,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;cond)</span></div>
<div class="block">Once we create a compensation predicate, this method is responsible for pushing
the resulting filter through the view nodes. This might be useful for rewritings
containing Aggregate operators, as some of the grouping columns might be removed,
which results in additional matching possibilities.
<p>The method will return a pair of nodes: the new top project on the left and
the new node on the right.</div>
</section>
</li>
<li>
<section class="detail" id="extractReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.RelNode)">
<h3>extractReferences</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;</span>&nbsp;<span class="element-name">extractReferences</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node)</span></div>
<div class="block">If the node is an Aggregate, it returns a list of references to the grouping columns.
Otherwise, it returns a list of references to all columns in the node.
The returned list is immutable.</div>
</section>
</li>
<li>
<section class="detail" id="generateTableMappings(com.google.common.collect.Multimap)">
<h3>generateTableMappings</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&gt;</span>&nbsp;<span class="element-name">generateTableMappings</span><wbr><span class="parameters">(com.google.common.collect.Multimap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;multiMapTables)</span></div>
<div class="block">It will flatten a multimap containing table references to table references,
producing all possible combinations of mappings. Each of the mappings will
be bi-directional.</div>
</section>
</li>
<li>
<section class="detail" id="isValidRelNodePlan(org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery)">
<h3>isValidRelNodePlan</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name">isValidRelNodePlan</span><wbr><span class="parameters">(<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq)</span></div>
<div class="block">Returns whether a RelNode is a valid tree. Currently we only support
TableScan - Project - Filter - Inner Join.</div>
</section>
</li>
<li>
<section class="detail" id="splitPredicates(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexNode)">
<h3>splitPredicates</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type"><a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;</span>&nbsp;<span class="element-name">splitPredicates</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;pred)</span></div>
<div class="block">Classifies each of the predicates in the list into one of these two
categories:
<ul>
<li> 1-l) column equality predicates, or
<li> 2-r) residual predicates, all the rest
</ul>
<p>For each category, it creates the conjunction of the predicates. The
result is an pair of RexNode objects corresponding to each category.</div>
</section>
</li>
<li>
<section class="detail" id="compensatePartial(java.util.Set,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,java.util.Set,com.google.common.collect.Multimap)">
<h3>compensatePartial</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name">compensatePartial</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;sourceTableRefs,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;sourceEC,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;targetTableRefs,
@Nullable com.google.common.collect.Multimap&lt;<a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex">RexTableInputRef</a>,<wbr><a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex">RexTableInputRef</a>&gt;&nbsp;compensationEquiColumns)</span></div>
<div class="block">It checks whether the target can be rewritten using the source even though the
source uses additional tables. In order to do that, we need to double-check
that every join that exists in the source and is not in the target is a
cardinality-preserving join, i.e., it only appends columns to the row
without changing its multiplicity. Thus, the join needs to be:
<ul>
<li> Equi-join </li>
<li> Between all columns in the keys </li>
<li> Foreign-key columns do not allow NULL values </li>
<li> Foreign-key </li>
<li> Unique-key </li>
</ul>
<p>If it can be rewritten, it returns true. Further, it inserts the missing equi-join
predicates in the input <code>compensationEquiColumns</code> multimap if it is provided.
If it cannot be rewritten, it returns false.</div>
</section>
</li>
<li>
<section class="detail" id="computeCompensationPredicates(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexSimplify,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.util.Pair,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.util.Pair,com.google.common.collect.BiMap)">
<h3>computeCompensationPredicates</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">@Nullable <a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;</span>&nbsp;<span class="element-name">computeCompensationPredicates</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexSimplify.html" title="class in org.apache.calcite.rex">RexSimplify</a>&nbsp;simplify,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;sourceEC,
<a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;sourcePreds,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;targetEC,
<a href="../../../util/Pair.html" title="class in org.apache.calcite.util">Pair</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;targetPreds,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;sourceToTargetTableMapping)</span></div>
<div class="block">We check whether the predicates in the source are contained in the predicates
in the target. The method treats separately the equi-column predicates, the
range predicates, and the rest of predicates.
<p>If the containment is confirmed, we produce compensation predicates that
need to be added to the target to produce the results in the source. Thus,
if source and target expressions are equivalent, those predicates will be the
true constant.
<p>In turn, if containment cannot be confirmed, the method returns null.</div>
</section>
</li>
<li>
<section class="detail" id="generateEquivalenceClasses(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses)">
<h3>generateEquivalenceClasses</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">@Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></span>&nbsp;<span class="element-name">generateEquivalenceClasses</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;sourceEC,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;targetEC)</span></div>
<div class="block">Given the equi-column predicates of the source and the target and the
computed equivalence classes, it extracts possible mappings between
the equivalence classes.
<p>If there is no mapping, it returns null. If there is a exact match,
it will return a compensation predicate that evaluates to true.
Finally, if a compensation predicate needs to be enforced on top of
the target to make the equivalences classes match, it returns that
compensation predicate.</div>
</section>
</li>
<li>
<section class="detail" id="extractPossibleMapping(java.util.List,java.util.List)">
<h3>extractPossibleMapping</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">@Nullable com.google.common.collect.Multimap&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>&gt;</span>&nbsp;<span class="element-name">extractPossibleMapping</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex">RexTableInputRef</a>&gt;&gt;&nbsp;sourceEquivalenceClasses,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex">RexTableInputRef</a>&gt;&gt;&nbsp;targetEquivalenceClasses)</span></div>
<div class="block">Given the source and target equivalence classes, it extracts the possible mappings
from each source equivalence class to each target equivalence class.
<p>If any of the source equivalence classes cannot be mapped to a target equivalence
class, it returns null.</div>
</section>
</li>
<li>
<section class="detail" id="rewriteExpression(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode,java.util.List,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,boolean,org.apache.calcite.rex.RexNode)">
<h3>rewriteExpression</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">@Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></span>&nbsp;<span class="element-name">rewriteExpression</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;targetNode,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;nodeExprs,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;tableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;ec,
boolean&nbsp;swapTableColumn,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;exprToRewrite)</span></div>
<div class="block">First, the method takes the node expressions <code>nodeExprs</code> and swaps the table
and column references using the table mapping and the equivalence classes.
If <code>swapTableColumn</code> is true, it swaps the table reference and then the column reference,
otherwise it swaps the column reference and then the table reference.
<p>Then, the method will rewrite the input expression <code>exprToRewrite</code>, replacing the
<a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex"><code>RexTableInputRef</code></a> by references to the positions in <code>nodeExprs</code>.
<p>The method will return the rewritten expression. If any of the expressions in the input
expression cannot be mapped, it will return null.</div>
</section>
</li>
<li>
<section class="detail" id="rewriteExpressions(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.RelNode,java.util.List,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,boolean,java.util.List)">
<h3>rewriteExpressions</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">@Nullable <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;</span>&nbsp;<span class="element-name">rewriteExpressions</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;targetNode,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;nodeExprs,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;tableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;ec,
boolean&nbsp;swapTableColumn,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;exprsToRewrite)</span></div>
<div class="block">First, the method takes the node expressions <code>nodeExprs</code> and swaps the table
and column references using the table mapping and the equivalence classes.
If <code>swapTableColumn</code> is true, it swaps the table reference and then the column reference,
otherwise it swaps the column reference and then the table reference.
<p>Then, the method will rewrite the input expressions <code>exprsToRewrite</code>, replacing the
<a href="../../../rex/RexTableInputRef.html" title="class in org.apache.calcite.rex"><code>RexTableInputRef</code></a> by references to the positions in <code>nodeExprs</code>.
<p>The method will return the rewritten expressions. If any of the subexpressions in the input
expressions cannot be mapped, it will return null.</div>
</section>
</li>
<li>
<section class="detail" id="generateSwapTableColumnReferencesLineage(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,java.util.List)">
<h3>generateSwapTableColumnReferencesLineage</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type"><a href="MaterializedViewRule.NodeLineage.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.NodeLineage</a></span>&nbsp;<span class="element-name">generateSwapTableColumnReferencesLineage</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;tableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;ec,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;nodeExprs)</span></div>
<div class="block">It swaps the table references and then the column references of the input
expressions using the table mapping and the equivalence classes.</div>
</section>
</li>
<li>
<section class="detail" id="generateSwapColumnTableReferencesLineage(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.rel.RelNode,com.google.common.collect.BiMap,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.EquivalenceClasses,java.util.List)">
<h3>generateSwapColumnTableReferencesLineage</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type"><a href="MaterializedViewRule.NodeLineage.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.NodeLineage</a></span>&nbsp;<span class="element-name">generateSwapColumnTableReferencesLineage</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../metadata/RelMetadataQuery.html" title="class in org.apache.calcite.rel.metadata">RelMetadataQuery</a>&nbsp;mq,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
com.google.common.collect.BiMap&lt;<a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>,<wbr><a href="../../../rex/RexTableInputRef.RelTableRef.html" title="class in org.apache.calcite.rex">RexTableInputRef.RelTableRef</a>&gt;&nbsp;tableMapping,
<a href="MaterializedViewRule.EquivalenceClasses.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.EquivalenceClasses</a>&nbsp;ec,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&gt;&nbsp;nodeExprs)</span></div>
<div class="block">It swaps the column references and then the table references of the input
expressions using the equivalence classes and the table mapping.</div>
</section>
</li>
<li>
<section class="detail" id="replaceWithOriginalReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rel.RelNode,org.apache.calcite.rel.rules.materialize.MaterializedViewRule.NodeLineage,org.apache.calcite.rex.RexNode)">
<h3>replaceWithOriginalReferences</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type"><a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></span>&nbsp;<span class="element-name">replaceWithOriginalReferences</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
<a href="MaterializedViewRule.NodeLineage.html" title="class in org.apache.calcite.rel.rules.materialize">MaterializedViewRule.NodeLineage</a>&nbsp;nodeLineage,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;exprToRewrite)</span></div>
<div class="block">Given the input expression, it will replace (sub)expressions when possible
using the content of the mapping. In particular, the mapping contains the
digest of the expression and the index that the replacement input ref should
point to.</div>
</section>
</li>
<li>
<section class="detail" id="shuttleReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexNode,org.apache.calcite.util.mapping.Mapping)">
<h3>shuttleReferences</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">@Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></span>&nbsp;<span class="element-name">shuttleReferences</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;node,
<a href="../../../util/mapping/Mapping.html" title="interface in org.apache.calcite.util.mapping">Mapping</a>&nbsp;mapping)</span></div>
<div class="block">Replaces all the input references by the position in the
input column set. If a reference index cannot be found in
the input set, then we return null.</div>
</section>
</li>
<li>
<section class="detail" id="shuttleReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexNode,com.google.common.collect.Multimap)">
<h3>shuttleReferences</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">@Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></span>&nbsp;<span class="element-name">shuttleReferences</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;expr,
com.google.common.collect.Multimap&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>&gt;&nbsp;exprsLineage)</span></div>
<div class="block">Replaces all the possible sub-expressions by input references
to the input node.</div>
</section>
</li>
<li>
<section class="detail" id="shuttleReferences(org.apache.calcite.rex.RexBuilder,org.apache.calcite.rex.RexNode,com.google.common.collect.Multimap,org.apache.calcite.rel.RelNode,com.google.common.collect.Multimap)">
<h3>shuttleReferences</h3>
<div class="member-signature"><span class="modifiers">protected</span>&nbsp;<span class="return-type">@Nullable <a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a></span>&nbsp;<span class="element-name">shuttleReferences</span><wbr><span class="parameters">(<a href="../../../rex/RexBuilder.html" title="class in org.apache.calcite.rex">RexBuilder</a>&nbsp;rexBuilder,
<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>&nbsp;expr,
com.google.common.collect.Multimap&lt;<a href="../../../rex/RexNode.html" title="class in org.apache.calcite.rex">RexNode</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>&gt;&nbsp;exprsLineage,
@Nullable <a href="../../RelNode.html" title="interface in org.apache.calcite.rel">RelNode</a>&nbsp;node,
@Nullable com.google.common.collect.Multimap&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html" title="class or interface in java.lang" class="external-link">Integer</a>&gt;&nbsp;rewritingMapping)</span></div>
<div class="block">Replaces all the possible sub-expressions by input references
to the input node. If available, it uses the rewriting mapping
to change the position to reference. Takes the reference type
from the input node.</div>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
<!-- ========= END OF CLASS DATA ========= -->
</main>
<footer role="contentinfo">
<hr>
<p class="legal-copy"><small>Copyright &copy; 2012-2023 Apache Software Foundation. All Rights Reserved.</small></p>
</footer>
</div>
</div>
</body>
</html>