blob: 9cb3437748ce2a53ad6e9d0cd4a4dac633a0f5a4 [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>TypeCoercionImpl (Apache 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="TypeCoercionImpl (Apache Calcite API)";
}
}
catch(err) {
}
//-->
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":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="class-use/TypeCoercionImpl.html">Use</a></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>
<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><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&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 TypeCoercionImpl" class="title">Class TypeCoercionImpl</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li><a href="AbstractTypeCoercion.html" title="class in org.apache.calcite.sql.validate.implicit">org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion</a></li>
<li>
<ul class="inheritance">
<li>org.apache.calcite.sql.validate.implicit.TypeCoercionImpl</li>
</ul>
</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>
<hr>
<pre>public class <span class="typeNameLabel">TypeCoercionImpl</span>
extends <a href="AbstractTypeCoercion.html" title="class in org.apache.calcite.sql.validate.implicit">AbstractTypeCoercion</a></pre>
<div class="block">Default implementation of Calcite implicit type cast.</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>
<ul class="blockList">
<li class="blockList"><a id="fields.inherited.from.class.org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion">
<!-- -->
</a>
<h3>Fields inherited from class&nbsp;org.apache.calcite.sql.validate.implicit.<a href="AbstractTypeCoercion.html" title="class in org.apache.calcite.sql.validate.implicit">AbstractTypeCoercion</a></h3>
<code><a href="AbstractTypeCoercion.html#factory">factory</a>, <a href="AbstractTypeCoercion.html#validator">validator</a></code></li>
</ul>
</li>
</ul>
</section>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E(org.apache.calcite.sql.validate.SqlValidator)">TypeCoercionImpl</a></span>&#8203;(<a href="../SqlValidator.html" title="interface in org.apache.calcite.sql.validate">SqlValidator</a>&nbsp;validator)</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>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#binaryArithmeticCoercion(org.apache.calcite.sql.SqlCallBinding)">binaryArithmeticCoercion</a></span>&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding)</code></th>
<td class="colLast">
<div class="block">Coerce operands in binary arithmetic expressions to Numeric types.</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="#binaryArithmeticWithStrings(org.apache.calcite.sql.SqlCallBinding,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">binaryArithmeticWithStrings</a></span>&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;right)</code></th>
<td class="colLast">
<div class="block">For numeric and string operands, cast string to data type of the other operand.</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="#booleanEquality(org.apache.calcite.sql.SqlCallBinding,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">booleanEquality</a></span>&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;right)</code></th>
<td class="colLast">
<div class="block">Cast "BOOLEAN = NUMERIC" to "NUMERIC = NUMERIC".</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#builtinFunctionCoercion(org.apache.calcite.sql.SqlCallBinding,java.util.List,java.util.List)">builtinFunctionCoercion</a></span>&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
java.util.List&lt;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&gt;&nbsp;operandTypes,
java.util.List&lt;<a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type">SqlTypeFamily</a>&gt;&nbsp;expectedFamilies)</code></th>
<td class="colLast">
<div class="block">Type coercion with inferred type from passed in arguments 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="i4" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#caseWhenCoercion(org.apache.calcite.sql.SqlCallBinding)">caseWhenCoercion</a></span>&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;callBinding)</code></th>
<td class="colLast">
<div class="block">Case when and COALESCE type coercion, collect all the branches types including then
operands and else operands to find a common type, then cast the operands to the common type
if it is needed.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>protected boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#dateTimeStringEquality(org.apache.calcite.sql.SqlCallBinding,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">dateTimeStringEquality</a></span>&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;right)</code></th>
<td class="colLast">
<div class="block">Datetime and string equality: cast string type to datetime type, SqlToRelConverter already
make the conversion but we still keep this interface overridable
so user can have their custom implementation.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#inOperationCoercion(org.apache.calcite.sql.SqlCallBinding)">inOperationCoercion</a></span>&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding)</code></th>
<td class="colLast">
<div class="block">STRATEGIES</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#rowTypeCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)">rowTypeCoercion</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;targetType)</code></th>
<td class="colLast">
<div class="block">Widen a SqlNode's field type to target type,
mainly used for set operations like UNION, INTERSECT and EXCEPT.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#userDefinedFunctionCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.sql.SqlFunction)">userDefinedFunctionCoercion</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="../../SqlFunction.html" title="class in org.apache.calcite.sql">SqlFunction</a>&nbsp;function)</code></th>
<td class="colLast">
<div class="block">Type coercion for user defined functions(UDFs).</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;org.apache.calcite.sql.validate.implicit.<a href="AbstractTypeCoercion.html" title="class in org.apache.calcite.sql.validate.implicit">AbstractTypeCoercion</a></h3>
<code><a href="AbstractTypeCoercion.html#canImplicitTypeCast(java.util.List,java.util.List)">canImplicitTypeCast</a>, <a href="AbstractTypeCoercion.html#coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNodeList,int,org.apache.calcite.rel.type.RelDataType)">coerceColumnType</a>, <a href="AbstractTypeCoercion.html#coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,int,org.apache.calcite.rel.type.RelDataType)">coerceOperandType</a>, <a href="AbstractTypeCoercion.html#commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">commonTypeForBinaryComparison</a>, <a href="AbstractTypeCoercion.html#getFactory()">getFactory</a>, <a href="AbstractTypeCoercion.html#getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getTightestCommonType</a>, <a href="AbstractTypeCoercion.html#getValidator()">getValidator</a>, <a href="AbstractTypeCoercion.html#getWiderTypeFor(java.util.List,boolean)">getWiderTypeFor</a>, <a href="AbstractTypeCoercion.html#getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getWiderTypeForDecimal</a>, <a href="AbstractTypeCoercion.html#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)">getWiderTypeForTwo</a>, <a href="AbstractTypeCoercion.html#implicitCast(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.type.SqlTypeFamily)">implicitCast</a>, <a href="AbstractTypeCoercion.html#needToCast(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">needToCast</a>, <a href="AbstractTypeCoercion.html#syncAttributes(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">syncAttributes</a>, <a href="AbstractTypeCoercion.html#updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)">updateInferredColumnType</a>, <a href="AbstractTypeCoercion.html#updateInferredType(org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">updateInferredType</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a id="&lt;init&gt;(org.apache.calcite.sql.validate.SqlValidator)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>TypeCoercionImpl</h4>
<pre>public&nbsp;TypeCoercionImpl&#8203;(<a href="../SqlValidator.html" title="interface in org.apache.calcite.sql.validate">SqlValidator</a>&nbsp;validator)</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="rowTypeCoercion(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>rowTypeCoercion</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;rowTypeCoercion&#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;targetType)</pre>
<div class="block">Widen a SqlNode's field type to target type,
mainly used for set operations like UNION, INTERSECT and EXCEPT.
<p>Rules:
<pre>
type1, type2 type3 select a, b, c from t1
| | |
type4 type5 type6 union
| | |
type7 type8 type9 select d, e, f from t2
</pre>
For struct type (type1, type2, type3) union type (type4, type5, type6),
infer the first result column type type7 as the wider type of type1 and type4,
the second column type as the wider type of type2 and type5 and so forth.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>scope</code> - validator scope</dd>
<dd><code>query</code> - query node to update the field type for</dd>
<dd><code>columnIndex</code> - target column index</dd>
<dd><code>targetType</code> - target type to cast to</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if any type coercion actually happens.</dd>
</dl>
</li>
</ul>
<a id="binaryArithmeticCoercion(org.apache.calcite.sql.SqlCallBinding)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binaryArithmeticCoercion</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;binaryArithmeticCoercion&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding)</pre>
<div class="block">Coerce operands in binary arithmetic expressions to Numeric types.
<p>Rules:</p>
<ul>
<li>For binary arithmetic operators like [+, -, *, /, %]: 1. If the operand is VARCHAR type,
coerce it to data type of the other operand if its data type is NUMERIC.</li>
<li>For EQUALS(=) operator: 1. If operands are BOOLEAN and NUMERIC, evaluate
`1=true` and `0=false` all to be true; 2. If operands are datetime and string,
do nothing because the SqlToRelConverter already makes the type coercion.</li>
<li>For binary comparision [=, &gt;, &gt;=, &lt;, &lt;=]: try to find the common type,
i.e. "1 &gt; '1'" will be converted to "1 &gt; 1".</li>
<li>Some single agg functions: coerce string operand to DECIMAL type.</li>
</ul></div>
</li>
</ul>
<a id="binaryArithmeticWithStrings(org.apache.calcite.sql.SqlCallBinding,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binaryArithmeticWithStrings</h4>
<pre class="methodSignature">protected&nbsp;boolean&nbsp;binaryArithmeticWithStrings&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;right)</pre>
<div class="block">For numeric and string operands, cast string to data type of the other operand.</div>
</li>
</ul>
<a id="dateTimeStringEquality(org.apache.calcite.sql.SqlCallBinding,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>dateTimeStringEquality</h4>
<pre class="methodSignature">protected&nbsp;boolean&nbsp;dateTimeStringEquality&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;right)</pre>
<div class="block">Datetime and string equality: cast string type to datetime type, SqlToRelConverter already
make the conversion but we still keep this interface overridable
so user can have their custom implementation.</div>
</li>
</ul>
<a id="booleanEquality(org.apache.calcite.sql.SqlCallBinding,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>booleanEquality</h4>
<pre class="methodSignature">protected&nbsp;boolean&nbsp;booleanEquality&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;right)</pre>
<div class="block">Cast "BOOLEAN = NUMERIC" to "NUMERIC = NUMERIC". Expressions like 1=`expr` and
0=`expr` can be simplified to `expr` and `not expr`, but this better happens
in <a href="../../../rex/RexSimplify.html" title="class in org.apache.calcite.rex"><code>RexSimplify</code></a>.
There are 2 cases that need type coercion here:
<ol>
<li>Case1: `boolean expr1` = 1 or `boolean expr1` = 0, replace the numeric literal with
`true` or `false` boolean literal.</li>
<li>Case2: `boolean expr1` = `numeric expr2`, replace expr1 to `1` or `0` numeric
literal.</li>
</ol>
For case2, wrap the operand in a cast operator, during sql-to-rel conversion
we would convert expression `cast(expr1 as right)` to `case when expr1 then 1 else 0.`</div>
</li>
</ul>
<a id="caseWhenCoercion(org.apache.calcite.sql.SqlCallBinding)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>caseWhenCoercion</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;caseWhenCoercion&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;callBinding)</pre>
<div class="block">Case when and COALESCE type coercion, collect all the branches types including then
operands and else operands to find a common type, then cast the operands to the common type
if it is needed.</div>
</li>
</ul>
<a id="inOperationCoercion(org.apache.calcite.sql.SqlCallBinding)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>inOperationCoercion</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;inOperationCoercion&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding)</pre>
<div class="block">STRATEGIES
<p>with/Without sub-query:
<ul>
<li>With sub-query: find the common type through comparing the left hand
side (LHS) expression types with corresponding right hand side (RHS)
expression derived from the sub-query expression's row type. Wrap the
fields of the LHS and RHS in CAST operators if it is needed.
<li>Without sub-query: convert the nodes of the RHS to the common type by
checking all the argument types and find out the minimum common type that
all the arguments can be cast to.
</ul>
<p>How to find the common type:
<ul>
<li>For both struct sql types (LHS and RHS), find the common type of every
LHS and RHS fields pair:
<pre>
(field1, field2, field3) (field4, field5, field6)
| | | | | |
+--------+---type1----------+ | |
| | | |
+-------+----type2---------+ |
| |
+-------------type3--------+
</pre>
</li>
<li>For both basic sql types(LHS and RHS),
find the common type of LHS and RHS nodes.</li>
</ul></div>
</li>
</ul>
<a id="builtinFunctionCoercion(org.apache.calcite.sql.SqlCallBinding,java.util.List,java.util.List)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>builtinFunctionCoercion</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;builtinFunctionCoercion&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
java.util.List&lt;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&gt;&nbsp;operandTypes,
java.util.List&lt;<a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type">SqlTypeFamily</a>&gt;&nbsp;expectedFamilies)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="TypeCoercion.html#builtinFunctionCoercion(org.apache.calcite.sql.SqlCallBinding,java.util.List,java.util.List)">TypeCoercion</a></code></span></div>
<div class="block">Type coercion with inferred type from passed in arguments 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 if desired type family is also
<a href="../../type/SqlTypeFamily.html#NUMERIC"><code>SqlTypeFamily.NUMERIC</code></a>.
<p>If the <a href="../../type/FamilyOperandTypeChecker.html" title="class in org.apache.calcite.sql.type"><code>FamilyOperandTypeChecker</code></a>s are
subsumed in a
<a href="../../type/CompositeOperandTypeChecker.html" title="class in org.apache.calcite.sql.type"><code>CompositeOperandTypeChecker</code></a>, check them
based on their combination order. i.e. If we allows a (numeric, numeric) OR
(string, numeric) family but with arguments (op1, op2) of types
(varchar(20), boolean), try to coerce op1 to numeric and op2 to numeric if
the type coercion rules allow it, or else try to coerce op2 to numeric and
keep op1 the type as it is.
<p>This is also very interrelated to the composition predicate for the
checkers: if the predicate is AND, we would fail fast if the first family
type coercion fails.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>binding</code> - Call binding</dd>
<dd><code>operandTypes</code> - Types of the operands passed in</dd>
<dd><code>expectedFamilies</code> - Expected SqlTypeFamily list by user specified</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if we successfully do any implicit cast</dd>
</dl>
</li>
</ul>
<a id="userDefinedFunctionCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.sql.SqlFunction)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>userDefinedFunctionCoercion</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;userDefinedFunctionCoercion&#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="../../SqlFunction.html" title="class in org.apache.calcite.sql">SqlFunction</a>&nbsp;function)</pre>
<div class="block">Type coercion for user defined functions(UDFs).</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if any operands is coerced</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="class-use/TypeCoercionImpl.html">Use</a></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>
<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><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&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 &#169; 2012&#x2013;2019 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</footer>
</body>
</html>