blob: 6e5f97a3866d81eb67a3458eae6a7772c39d5dae [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>AbstractTypeCoercion (Apache Calcite calcite API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../../../jquery/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../../../../../jquery/jquery-migrate-3.0.1.js"></script>
<script type="text/javascript" src="../../../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="AbstractTypeCoercion (Apache Calcite calcite API)";
}
}
catch(err) {
}
//-->
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">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">Help</a></li>
</ul>
<div class="aboutLanguage"><b>Apache Calcite</b></div>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&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="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">org.apache.calcite.sql.validate.implicit</a></div>
<h2 title="Class AbstractTypeCoercion" class="title">Class AbstractTypeCoercion</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><code><a href="TypeCoercionImpl.html" title="class in org.apache.calcite.sql.validate.implicit">TypeCoercionImpl</a></code></dd>
</dl>
<hr>
<pre>public abstract class <span class="typeNameLabel">AbstractTypeCoercion</span>
extends <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>
implements <a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></pre>
<div class="block">Base class for all the type coercion rules. If you want to have a custom type coercion rules,
inheriting this class is not necessary, but would have some convenient tool methods.
<p>We make tool methods: <a href="#coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,int,org.apache.calcite.rel.type.RelDataType)"><code>coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlCall, int, org.apache.calcite.rel.type.RelDataType)</code></a>, <a href="#coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNodeList,int,org.apache.calcite.rel.type.RelDataType)"><code>coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlNodeList, int, org.apache.calcite.rel.type.RelDataType)</code></a>,
<a href="#needToCast(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)"><code>needToCast(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlNode, org.apache.calcite.rel.type.RelDataType)</code></a>, <a href="#updateInferredType(org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)"><code>updateInferredType(org.apache.calcite.sql.SqlNode, org.apache.calcite.rel.type.RelDataType)</code></a>, <a href="#updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)"><code>updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlNode, int, org.apache.calcite.rel.type.RelDataType)</code></a>
all overridable by derived classes, you can define system specific type coercion logic.
<p>Caution that these methods may modify the <a href="../../SqlNode.html" title="class in org.apache.calcite.sql"><code>SqlNode</code></a> tree, you should know what the
effect is when using these methods to customize your type coercion rules.
<p>This class also defines the default implementation of the type widening strategies, see
<a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit"><code>TypeCoercion</code></a> doc and methods: <a href="#getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)"><code>getTightestCommonType(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType)</code></a>, <a href="#getWiderTypeFor(java.util.List,boolean)"><code>getWiderTypeFor(java.util.List&lt;org.apache.calcite.rel.type.RelDataType&gt;, boolean)</code></a>,
<a href="#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)"><code>getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean)</code></a>, <a href="#getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)"><code>getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType)</code></a>,
<a href="#commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)"><code>commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType)</code></a> for the detail strategies.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="memberSummary">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Field</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected <a href="../../../rel/type/RelDataTypeFactory.html" title="interface in org.apache.calcite.rel.type">RelDataTypeFactory</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#factory">factory</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>protected <a href="../SqlValidator.html" title="interface in org.apache.calcite.sql.validate">SqlValidator</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#validator">validator</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
</table>
</li>
</ul>
</section>
<!-- ========== METHOD SUMMARY =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>protected boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNodeList,int,org.apache.calcite.rel.type.RelDataType)">coerceColumnType</a></span>&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNodeList.html" title="class in org.apache.calcite.sql">SqlNodeList</a>&nbsp;nodeList,
int&nbsp;index,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetType)</code></th>
<td class="colLast">
<div class="block">Cast column at index <code>index</code> to target type.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>protected boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#coerceOperandsType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.rel.type.RelDataType)">coerceOperandsType</a></span>&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;commonType)</code></th>
<td class="colLast">
<div class="block">Coerce all the operands to <code>commonType</code>.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>protected boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,int,org.apache.calcite.rel.type.RelDataType)">coerceOperandType</a></span>&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
int&nbsp;index,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetType)</code></th>
<td class="colLast">
<div class="block">Cast operand at index <code>index</code> to target type.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code><a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">commonTypeForBinaryComparison</a></span>&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</code></th>
<td class="colLast">
<div class="block">Determines common type for a comparison operator when one operand is String type and the
other is not.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code><a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getTightestCommonType</a></span>&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</code></th>
<td class="colLast">
<div class="block">Case1: type widening with no precision loss.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code><a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getWiderTypeFor(java.util.List,boolean)">getWiderTypeFor</a></span>&#8203;(<a href="https://docs.oracle.com/javase/9/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util" class="externalLink">List</a>&lt;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&gt;&nbsp;typeList,
boolean&nbsp;stringPromotion)</code></th>
<td class="colLast">
<div class="block">Similar to <a href="#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)"><code>getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean)</code></a>, but can handle
sequence types.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code><a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getWiderTypeForDecimal</a></span>&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</code></th>
<td class="colLast">
<div class="block">Finds a wider type when one or both types are decimal type.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code><a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)">getWiderTypeForTwo</a></span>&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2,
boolean&nbsp;stringPromotion)</code></th>
<td class="colLast">
<div class="block">Case2: type widening.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code><a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#implicitCast(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.type.SqlTypeFamily)">implicitCast</a></span>&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;in,
<a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type">SqlTypeFamily</a>&nbsp;expected)</code></th>
<td class="colLast">
<div class="block">Type coercion based on the inferred type from passed in operand
and the <a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type"><code>SqlTypeFamily</code></a> defined in the checkers,
e.g.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>protected boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#needToCast(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">needToCast</a></span>&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;node,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;toType)</code></th>
<td class="colLast">
<div class="block">Decide if a SqlNode should be casted to target type, derived class
can override this strategy.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>protected void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)">updateInferredColumnType</a></span>&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;query,
int&nbsp;columnIndex,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;desiredType)</code></th>
<td class="colLast">
<div class="block">Update inferred row type for a query, i.e.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>protected void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#updateInferredType(org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">updateInferredType</a></span>&#8203;(<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;node,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type)</code></th>
<td class="colLast">
<div class="block">Update inferred type for a SqlNode.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a></h3>
<code><a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang" class="externalLink">clone</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang" class="externalLink">equals</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang" class="externalLink">finalize</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang" class="externalLink">getClass</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang" class="externalLink">hashCode</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang" class="externalLink">notify</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang" class="externalLink">notifyAll</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang" class="externalLink">toString</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#wait(long,int)" title="class or interface in java.lang" class="externalLink">wait</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.org.apache.calcite.sql.validate.implicit.TypeCoercion">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;org.apache.calcite.sql.validate.implicit.<a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></h3>
<code><a href="TypeCoercion.html#binaryArithmeticCoercion(org.apache.calcite.sql.SqlCallBinding)">binaryArithmeticCoercion</a>, <a href="TypeCoercion.html#binaryComparisonCoercion(org.apache.calcite.sql.SqlCallBinding)">binaryComparisonCoercion</a>, <a href="TypeCoercion.html#builtinFunctionCoercion(org.apache.calcite.sql.SqlCallBinding,java.util.List,java.util.List)">builtinFunctionCoercion</a>, <a href="TypeCoercion.html#caseWhenCoercion(org.apache.calcite.sql.SqlCallBinding)">caseWhenCoercion</a>, <a href="TypeCoercion.html#inOperationCoercion(org.apache.calcite.sql.SqlCallBinding)">inOperationCoercion</a>, <a href="TypeCoercion.html#querySourceCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.SqlNode)">querySourceCoercion</a>, <a href="TypeCoercion.html#rowTypeCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)">rowTypeCoercion</a>, <a href="TypeCoercion.html#userDefinedFunctionCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.sql.SqlFunction)">userDefinedFunctionCoercion</a></code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a id="validator">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>validator</h4>
<pre>protected&nbsp;<a href="../SqlValidator.html" title="interface in org.apache.calcite.sql.validate">SqlValidator</a> validator</pre>
</li>
</ul>
<a id="factory">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>factory</h4>
<pre>protected&nbsp;<a href="../../../rel/type/RelDataTypeFactory.html" title="interface in org.apache.calcite.rel.type">RelDataTypeFactory</a> factory</pre>
</li>
</ul>
</li>
</ul>
</section>
<!-- ============ METHOD DETAIL ========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a id="coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,int,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>coerceOperandType</h4>
<pre class="methodSignature">protected&nbsp;boolean&nbsp;coerceOperandType&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
int&nbsp;index,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetType)</pre>
<div class="block">Cast operand at index <code>index</code> to target type.
we do this base on the fact that validate happens before type coercion.</div>
</li>
</ul>
<a id="coerceOperandsType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>coerceOperandsType</h4>
<pre class="methodSignature">protected&nbsp;boolean&nbsp;coerceOperandsType&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;commonType)</pre>
<div class="block">Coerce all the operands to <code>commonType</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>scope</code> - Validator scope</dd>
<dd><code>call</code> - the call</dd>
<dd><code>commonType</code> - common type to coerce to</dd>
</dl>
</li>
</ul>
<a id="coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNodeList,int,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>coerceColumnType</h4>
<pre class="methodSignature">protected&nbsp;boolean&nbsp;coerceColumnType&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNodeList.html" title="class in org.apache.calcite.sql">SqlNodeList</a>&nbsp;nodeList,
int&nbsp;index,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetType)</pre>
<div class="block">Cast column at index <code>index</code> to target type.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>scope</code> - Validator scope for the node list</dd>
<dd><code>nodeList</code> - Column node list</dd>
<dd><code>index</code> - Index of column</dd>
<dd><code>targetType</code> - Target type to cast to</dd>
</dl>
</li>
</ul>
<a id="needToCast(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>needToCast</h4>
<pre class="methodSignature">protected&nbsp;boolean&nbsp;needToCast&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;node,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;toType)</pre>
<div class="block">Decide if a SqlNode should be casted to target type, derived class
can override this strategy.</div>
</li>
</ul>
<a id="updateInferredType(org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>updateInferredType</h4>
<pre class="methodSignature">protected&nbsp;void&nbsp;updateInferredType&#8203;(<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;node,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type)</pre>
<div class="block">Update inferred type for a SqlNode.</div>
</li>
</ul>
<a id="updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>updateInferredColumnType</h4>
<pre class="methodSignature">protected&nbsp;void&nbsp;updateInferredColumnType&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;query,
int&nbsp;columnIndex,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;desiredType)</pre>
<div class="block">Update inferred row type for a query, i.e. SqlCall that returns struct type
or SqlSelect.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>scope</code> - Validator scope</dd>
<dd><code>query</code> - Node to inferred type</dd>
<dd><code>columnIndex</code> - Column index to update</dd>
<dd><code>desiredType</code> - Desired column type</dd>
</dl>
</li>
</ul>
<a id="getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getTightestCommonType</h4>
<pre class="methodSignature">public&nbsp;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;getTightestCommonType&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</pre>
<div class="block">Case1: type widening with no precision loss.
Find the tightest common type of two types that might be used in binary expression.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getTightestCommonType</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>tightest common type, i.e. INTEGER + DECIMAL(10, 2) returns DECIMAL(10, 2)</dd>
</dl>
</li>
</ul>
<a id="commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>commonTypeForBinaryComparison</h4>
<pre class="methodSignature">public&nbsp;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;commonTypeForBinaryComparison&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</pre>
<div class="block">Determines common type for a comparison operator when one operand is String type and the
other is not. For date + timestamp operands, use timestamp as common type,
i.e. Timestamp(2017-01-01 00:00 ...) &gt; Date(2018) evaluates to be false.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">commonTypeForBinaryComparison</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
</li>
</ul>
<a id="getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getWiderTypeForTwo</h4>
<pre class="methodSignature">public&nbsp;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;getWiderTypeForTwo&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2,
boolean&nbsp;stringPromotion)</pre>
<div class="block">Case2: type widening. The main difference with <a href="#getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)"><code>getTightestCommonType(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType)</code></a>
is that we allow some precision loss when widening decimal to fractional,
or promote fractional to string type.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)">getWiderTypeForTwo</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
</li>
</ul>
<a id="getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getWiderTypeForDecimal</h4>
<pre class="methodSignature">public&nbsp;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;getWiderTypeForDecimal&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</pre>
<div class="block">Finds a wider type when one or both types are decimal type.
If the wider decimal type's precision/scale exceeds system limitation,
this rule will truncate the decimal type to the max precision/scale.
For decimal and fractional types, returns a decimal type
which has the higher precision of the two.
<p>The default implementation depends on the max precision/scale of the type system,
you can override it based on the specific system requirement in
<a href="../../../rel/type/RelDataTypeSystem.html" title="interface in org.apache.calcite.rel.type"><code>RelDataTypeSystem</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getWiderTypeForDecimal</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
</li>
</ul>
<a id="getWiderTypeFor(java.util.List,boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getWiderTypeFor</h4>
<pre class="methodSignature">public&nbsp;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;getWiderTypeFor&#8203;(<a href="https://docs.oracle.com/javase/9/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util" class="externalLink">List</a>&lt;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&gt;&nbsp;typeList,
boolean&nbsp;stringPromotion)</pre>
<div class="block">Similar to <a href="#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)"><code>getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean)</code></a>, but can handle
sequence types. <a href="#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)"><code>getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean)</code></a> doesn't satisfy the associative law,
i.e. (a op b) op c may not equal to a op (b op c). This is only a problem for STRING type or
nested STRING type in collection type like ARRAY. Excluding these types,
<a href="#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)"><code>getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean)</code></a> satisfies the associative law. For instance,
(DATE, INTEGER, VARCHAR) should have VARCHAR as the wider common type.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#getWiderTypeFor(java.util.List,boolean)">getWiderTypeFor</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
</li>
</ul>
<a id="implicitCast(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.type.SqlTypeFamily)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>implicitCast</h4>
<pre class="methodSignature">public&nbsp;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;implicitCast&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;in,
<a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type">SqlTypeFamily</a>&nbsp;expected)</pre>
<div class="block">Type coercion based on the inferred type from passed in operand
and the <a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type"><code>SqlTypeFamily</code></a> defined in the checkers,
e.g. the <a href="../../type/FamilyOperandTypeChecker.html" title="class in org.apache.calcite.sql.type"><code>FamilyOperandTypeChecker</code></a>.
<p>Caution that we do not cast from NUMERIC to NUMERIC.
See <a href="https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing">CalciteImplicitCasts</a>
for the details.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>in</code> - Inferred operand type</dd>
<dd><code>expected</code> - Expected <a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type"><code>SqlTypeFamily</code></a> of registered SqlFunction</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>common type of implicit cast, null if we do not find any</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">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">Help</a></li>
</ul>
<div class="aboutLanguage"><b>Apache Calcite</b></div>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&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="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small>Copyright &copy; 2012-2020 Apache Software Foundation. All Rights Reserved.</small></p>
</footer>
</body>
</html>