blob: 62d75a93cb4d90d526151986c18262e3db80b193 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>TypeCoercionImpl (Apache Calcite calcite API)</title>
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../../script.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 methods = {"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";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.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">
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionFactory.html" title="interface in org.apache.calcite.sql.validate.implicit"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercions.html" title="class in org.apache.calcite.sql.validate.implicit"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html" target="_top">Frames</a></li>
<li><a href="TypeCoercionImpl.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses-noframe.html">All&nbsp;Classes</a></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>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#fields.inherited.from.class.org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion">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 name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.calcite.sql.validate.implicit</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/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/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><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></dd>
</dl>
<hr>
<br>
<pre>public class <span class="typeNameLabel">TypeCoercionImpl</span>
extends <a href="../../../../../../org/apache/calcite/sql/validate/implicit/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 =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<ul class="blockList">
<li class="blockList"><a name="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="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html" title="class in org.apache.calcite.sql.validate.implicit">AbstractTypeCoercion</a></h3>
<code><a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#factory">factory</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#validator">validator</a></code></li>
</ul>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#TypeCoercionImpl-org.apache.calcite.rel.type.RelDataTypeFactory-org.apache.calcite.sql.validate.SqlValidator-">TypeCoercionImpl</a></span>(<a href="../../../../../../org/apache/calcite/rel/type/RelDataTypeFactory.html" title="interface in org.apache.calcite.rel.type">RelDataTypeFactory</a>&nbsp;typeFactory,
<a href="../../../../../../org/apache/calcite/sql/validate/SqlValidator.html" title="interface in org.apache.calcite.sql.validate">SqlValidator</a>&nbsp;validator)</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<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="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#binaryArithmeticCoercion-org.apache.calcite.sql.SqlCallBinding-">binaryArithmeticCoercion</a></span>(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#binaryArithmeticWithStrings-org.apache.calcite.sql.SqlCallBinding-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">binaryArithmeticWithStrings</a></span>(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;right)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#binaryComparisonCoercion-org.apache.calcite.sql.SqlCallBinding-">binaryComparisonCoercion</a></span>(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#booleanEquality-org.apache.calcite.sql.SqlCallBinding-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">booleanEquality</a></span>(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;right)</code>
<div class="block">Casts "BOOLEAN = NUMERIC" to "NUMERIC = NUMERIC".</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#builtinFunctionCoercion-org.apache.calcite.sql.SqlCallBinding-java.util.List-java.util.List-">builtinFunctionCoercion</a></span>(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&gt;&nbsp;operandTypes,
<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../../org/apache/calcite/sql/type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type">SqlTypeFamily</a>&gt;&nbsp;expectedFamilies)</code>
<div class="block">Type coercion with inferred type from passed in arguments and the
<a href="../../../../../../org/apache/calcite/sql/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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#caseWhenCoercion-org.apache.calcite.sql.SqlCallBinding-">caseWhenCoercion</a></span>(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;callBinding)</code>
<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="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#commonTypeForComparison-java.util.List-">commonTypeForComparison</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&gt;&nbsp;dataTypes)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#dateTimeStringEquality-org.apache.calcite.sql.SqlCallBinding-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">dateTimeStringEquality</a></span>(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;right)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#inOperationCoercion-org.apache.calcite.sql.SqlCallBinding-">inOperationCoercion</a></span>(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding)</code>
<div class="block">STRATEGIES</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.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></span>(<a href="../../../../../../org/apache/calcite/sql/validate/SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;sourceRowType,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetRowType,
<a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;query)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#rowTypeCoercion-org.apache.calcite.sql.validate.SqlValidatorScope-org.apache.calcite.sql.SqlNode-int-org.apache.calcite.rel.type.RelDataType-">rowTypeCoercion</a></span>(<a href="../../../../../../org/apache/calcite/sql/validate/SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;query,
int&nbsp;columnIndex,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetType)</code>
<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>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html#userDefinedFunctionCoercion-org.apache.calcite.sql.validate.SqlValidatorScope-org.apache.calcite.sql.SqlCall-org.apache.calcite.sql.SqlFunction-">userDefinedFunctionCoercion</a></span>(<a href="../../../../../../org/apache/calcite/sql/validate/SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/sql/SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
<a href="../../../../../../org/apache/calcite/sql/SqlFunction.html" title="class in org.apache.calcite.sql">SqlFunction</a>&nbsp;function)</code>
<div class="block">Type coercion for user defined functions(UDFs).</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="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="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html" title="class in org.apache.calcite.sql.validate.implicit">AbstractTypeCoercion</a></h3>
<code><a href="../../../../../../org/apache/calcite/sql/validate/implicit/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="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#coerceOperandsType-org.apache.calcite.sql.validate.SqlValidatorScope-org.apache.calcite.sql.SqlCall-org.apache.calcite.rel.type.RelDataType-">coerceOperandsType</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/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="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#commonTypeForBinaryComparison-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">commonTypeForBinaryComparison</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#getTightestCommonType-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">getTightestCommonType</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#getWiderTypeFor-java.util.List-boolean-">getWiderTypeFor</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#getWiderTypeForDecimal-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">getWiderTypeForDecimal</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#getWiderTypeForTwo-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-boolean-">getWiderTypeForTwo</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#implicitCast-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.sql.type.SqlTypeFamily-">implicitCast</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html#needToCast-org.apache.calcite.sql.validate.SqlValidatorScope-org.apache.calcite.sql.SqlNode-org.apache.calcite.rel.type.RelDataType-">needToCast</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/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="../../../../../../org/apache/calcite/sql/validate/implicit/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 name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="TypeCoercionImpl-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(<a href="../../../../../../org/apache/calcite/rel/type/RelDataTypeFactory.html" title="interface in org.apache.calcite.rel.type">RelDataTypeFactory</a>&nbsp;typeFactory,
<a href="../../../../../../org/apache/calcite/sql/validate/SqlValidator.html" title="interface in org.apache.calcite.sql.validate">SqlValidator</a>&nbsp;validator)</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="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>public&nbsp;boolean&nbsp;rowTypeCoercion(<a href="../../../../../../org/apache/calcite/sql/validate/SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;query,
int&nbsp;columnIndex,
<a href="../../../../../../org/apache/calcite/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 name="binaryArithmeticCoercion-org.apache.calcite.sql.SqlCallBinding-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binaryArithmeticCoercion</h4>
<pre>public&nbsp;boolean&nbsp;binaryArithmeticCoercion(<a href="../../../../../../org/apache/calcite/sql/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 name="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>protected&nbsp;boolean&nbsp;binaryArithmeticWithStrings(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/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 name="binaryComparisonCoercion-org.apache.calcite.sql.SqlCallBinding-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binaryComparisonCoercion</h4>
<pre>public&nbsp;boolean&nbsp;binaryComparisonCoercion(<a href="../../../../../../org/apache/calcite/sql/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 name="commonTypeForComparison-java.util.List-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>commonTypeForComparison</h4>
<pre>protected&nbsp;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;commonTypeForComparison(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../../org/apache/calcite/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 name="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>protected&nbsp;boolean&nbsp;dateTimeStringEquality(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/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 name="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>protected&nbsp;boolean&nbsp;booleanEquality(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/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="../../../../../../org/apache/calcite/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 name="caseWhenCoercion-org.apache.calcite.sql.SqlCallBinding-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>caseWhenCoercion</h4>
<pre>public&nbsp;boolean&nbsp;caseWhenCoercion(<a href="../../../../../../org/apache/calcite/sql/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 name="inOperationCoercion-org.apache.calcite.sql.SqlCallBinding-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>inOperationCoercion</h4>
<pre>public&nbsp;boolean&nbsp;inOperationCoercion(<a href="../../../../../../org/apache/calcite/sql/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 name="builtinFunctionCoercion-org.apache.calcite.sql.SqlCallBinding-java.util.List-java.util.List-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>builtinFunctionCoercion</h4>
<pre>public&nbsp;boolean&nbsp;builtinFunctionCoercion(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding,
<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&gt;&nbsp;operandTypes,
<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../../org/apache/calcite/sql/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="../../../../../../org/apache/calcite/sql/validate/implicit/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="../../../../../../org/apache/calcite/sql/type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type"><code>SqlTypeFamily</code></a> defined in the checkers, e.g. the
<a href="../../../../../../org/apache/calcite/sql/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="../../../../../../org/apache/calcite/sql/type/SqlTypeFamily.html#NUMERIC"><code>SqlTypeFamily.NUMERIC</code></a>.
<p>If the <a href="../../../../../../org/apache/calcite/sql/type/FamilyOperandTypeChecker.html" title="class in org.apache.calcite.sql.type"><code>FamilyOperandTypeChecker</code></a>s are
subsumed in a
<a href="../../../../../../org/apache/calcite/sql/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 name="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>public&nbsp;boolean&nbsp;userDefinedFunctionCoercion(<a href="../../../../../../org/apache/calcite/sql/validate/SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/sql/SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
<a href="../../../../../../org/apache/calcite/sql/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 name="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>public&nbsp;boolean&nbsp;querySourceCoercion(<a href="../../../../../../org/apache/calcite/sql/validate/SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;sourceRowType,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetRowType,
<a href="../../../../../../org/apache/calcite/sql/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="../../../../../../org/apache/calcite/sql/validate/implicit/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>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.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">
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionFactory.html" title="interface in org.apache.calcite.sql.validate.implicit"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercions.html" title="class in org.apache.calcite.sql.validate.implicit"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html" target="_top">Frames</a></li>
<li><a href="TypeCoercionImpl.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses-noframe.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>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#fields.inherited.from.class.org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion">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 name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &copy; 2012-2020 Apache Software Foundation. All Rights Reserved.</small></p>
</body>
</html>