blob: b78906a23b945dad37baa6b58be4208e2f37d312 [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>TypeCoercionImpl (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="TypeCoercionImpl (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><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><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><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.rel.type.RelDataTypeFactory,org.apache.calcite.sql.validate.SqlValidator)">TypeCoercionImpl</a></span>&#8203;(<a href="../../../rel/type/RelDataTypeFactory.html" title="interface in org.apache.calcite.rel.type">RelDataTypeFactory</a>&nbsp;typeFactory,
<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">Coerces 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>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#binaryComparisonCoercion(org.apache.calcite.sql.SqlCallBinding)">binaryComparisonCoercion</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">Coerces operands in binary comparison expressions.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<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">Casts "BOOLEAN = NUMERIC" to "NUMERIC = NUMERIC".</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="#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,
<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;operandTypes,
<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="../../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="i5" class="rowColor">
<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 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
when needed.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>protected <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="#commonTypeForComparison(java.util.List)">commonTypeForComparison</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;dataTypes)</code></th>
<td class="colLast">
<div class="block">Finds the common type for binary comparison
when the size of operands <code>dataTypes</code> is more than 2.</div>
</td>
</tr>
<tr id="i7" 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
makes the conversion but we still keep this interface overridable
so user can have their custom implementation.</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="#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">Handles type coercion for IN operation with or without sub-query.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#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></span>&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;sourceRowType,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetRowType,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;query)</code></th>
<td class="colLast">
<div class="block">Coerces the source row expression to target type in an INSERT or UPDATE query.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<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 common type,
mainly used for set operations like UNION, INTERSECT and EXCEPT.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<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#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#coerceOperandsType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.rel.type.RelDataType)">coerceOperandsType</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#getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getTightestCommonType</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#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.<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>
</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.rel.type.RelDataTypeFactory,org.apache.calcite.sql.validate.SqlValidator)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>TypeCoercionImpl</h4>
<pre>public&nbsp;TypeCoercionImpl&#8203;(<a href="../../../rel/type/RelDataTypeFactory.html" title="interface in org.apache.calcite.rel.type">RelDataTypeFactory</a>&nbsp;typeFactory,
<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 common 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 on.</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>
</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">Coerces operands in binary arithmetic expressions to NUMERIC types.
<p>For binary arithmetic operators like [+, -, *, /, %]:
If the operand is VARCHAR,
coerce it to data type of the other operand if its data type is NUMERIC;
If the other operand is DECIMAL,
coerce the STRING operand to max precision/scale DECIMAL.</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="binaryComparisonCoercion(org.apache.calcite.sql.SqlCallBinding)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binaryComparisonCoercion</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;binaryComparisonCoercion&#8203;(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding)</pre>
<div class="block">Coerces operands in binary comparison expressions.
<p>Rules:</p>
<ul>
<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>For BETWEEN operator, find the common comparison data type of all the operands,
the common type is deduced from left to right, i.e. for expression "A between B and C",
finds common comparison type D between A and B
then common comparison type E between D and C as the final common type.</li>
</ul></div>
</li>
</ul>
<a id="commonTypeForComparison(java.util.List)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>commonTypeForComparison</h4>
<pre class="methodSignature">protected&nbsp;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;commonTypeForComparison&#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;dataTypes)</pre>
<div class="block">Finds the common type for binary comparison
when the size of operands <code>dataTypes</code> is more than 2.
If there are N(more than 2) operands,
finds the common type between two operands from left to right:
<p>Rules:</p>
<pre>
type1 type2 type3
| | |
+- type4 -+ |
| |
+--- type5 ---+
</pre>
For operand data types (type1, type2, type3), deduce the common type type4
from type1 and type2, then common type type5 from type4 and type3.</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
makes 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">Casts "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>.
<p>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 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
when 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">Handles type coercion for IN operation with or without sub-query.
<p>See <a href="TypeCoercionImpl.html" title="class in org.apache.calcite.sql.validate.implicit"><code>TypeCoercionImpl</code></a> for default strategies.
<p>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>For both basic sql types(LHS and RHS),
find the common type of LHS and RHS nodes.
</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,
<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;operandTypes,
<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="../../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 allow a NUMERIC_NUMERIC OR
STRING_NUMERIC family combination and are with arguments (op1: VARCHAR(20), op2: BOOLEAN),
try to coerce both op1 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>
</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="blockList">
<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>
</li>
</ul>
<a id="querySourceCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.SqlNode)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>querySourceCoercion</h4>
<pre class="methodSignature">public&nbsp;boolean&nbsp;querySourceCoercion&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;sourceRowType,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetRowType,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;query)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><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)">TypeCoercion</a></code></span></div>
<div class="block">Coerces the source row expression to target type in an INSERT or UPDATE query.
<p>If the source and target fields in the same ordinal do not equal sans nullability,
try to coerce the source field to target field type.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>scope</code> - Source scope</dd>
<dd><code>sourceRowType</code> - Source row type</dd>
<dd><code>targetRowType</code> - Target row type</dd>
<dd><code>query</code> - The query, either an INSERT or UPDATE</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><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 &copy; 2012-2020 Apache Software Foundation. All Rights Reserved.</small></p>
</footer>
</body>
</html>