blob: 7d7c22b9c92f902ec1cf753a2c877cb6f8d61e90 [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>TypeCoercion (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="TypeCoercion (Apache Calcite calcite API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":6,"i2":6,"i3":6,"i4":6,"i5":6,"i6":6,"i7":6,"i8":6,"i9":6,"i10":6,"i11":6,"i12":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract 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/AbstractTypeCoercion.html" title="class 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/TypeCoercionFactory.html" title="interface 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/TypeCoercion.html" target="_top">Frames</a></li>
<li><a href="TypeCoercion.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>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&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="Interface TypeCoercion" class="title">Interface TypeCoercion</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html" title="class in org.apache.calcite.sql.validate.implicit">AbstractTypeCoercion</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html" title="class in org.apache.calcite.sql.validate.implicit">TypeCoercionImpl</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="typeNameLabel">TypeCoercion</span></pre>
<div class="block">Default strategies to coerce differing types that participate in
operations into compatible ones.
<p>Notes about type widening / tightest common types: Broadly, there are two cases that need
to widen data types (i.e. set operations, binary comparison):
<ul>
<li>Case1: Look for a common data type for two or more data types,
and no loss of precision is allowed. Including type inference for returned/operands
type (i.e. what's the column's common data type if one row is an integer while the
other row is a long?).</li>
<li>Case2: Look for a widen data type with some acceptable loss of precision
(i.e. there is no common type for double and decimal because double's range is larger than
decimal(with default max precision), and yet decimal is more precise than double,
but in union we would cast the decimal to double).</li>
</ul>
<p>REFERENCE: <a href="https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-type-conversion-database-engine?">SQL-SERVER</a>
<a href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types">HIVE</a></p></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== 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="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract 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/TypeCoercion.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 operand of binary arithmetic expressions to Numeric type.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.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="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/TypeCoercion.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="i3" class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.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;binding)</code>
<div class="block">Coerces CASE WHEN statement branches to one common type.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code><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/TypeCoercion.html#commonTypeForBinaryComparison-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">commonTypeForBinaryComparison</a></span>(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</code>
<div class="block">Determines common type for a comparison operator whose operands are STRING
type and the other (non STRING) type.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code><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/TypeCoercion.html#getTightestCommonType-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">getTightestCommonType</a></span>(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</code>
<div class="block">Case1: type widening with no precision loss.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code><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/TypeCoercion.html#getWiderTypeFor-java.util.List-boolean-">getWiderTypeFor</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;typeList,
boolean&nbsp;stringPromotion)</code>
<div class="block">Similar to <a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html#getWiderTypeForTwo-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-boolean-"><code>getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean)</code></a>, but can handle
sequence types.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code><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/TypeCoercion.html#getWiderTypeForDecimal-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">getWiderTypeForDecimal</a></span>(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</code>
<div class="block">Finds a wider type when one or both types are DECIMAL type.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code><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/TypeCoercion.html#getWiderTypeForTwo-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-boolean-">getWiderTypeForTwo</a></span>(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2,
boolean&nbsp;stringPromotion)</code>
<div class="block">Case2: type widening.</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/TypeCoercion.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">Handles type coercion for IN operation with or without sub-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/TypeCoercion.html#querySourceCoercion-org.apache.calcite.sql.validate.SqlValidatorScope-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.sql.SqlNode-">querySourceCoercion</a></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="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/TypeCoercion.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 ith column type to target type, mainly used for set
operations like UNION, INTERSECT and EXCEPT.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.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">Non built-in functions (UDFs) type coercion, compare the types of arguments
with rules:
Named param: find the desired type by the passed in operand's name
Non-named param: find the desired type by formal parameter ordinal
</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="getTightestCommonType-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getTightestCommonType</h4>
<pre><a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;getTightestCommonType(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</pre>
<div class="block">Case1: type widening with no precision loss.
Find the tightest common type of two types that might be used in binary expression.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>common type</dd>
</dl>
</li>
</ul>
<a name="getWiderTypeForTwo-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getWiderTypeForTwo</h4>
<pre><a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;getWiderTypeForTwo(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2,
boolean&nbsp;stringPromotion)</pre>
<div class="block">Case2: type widening. The main difference with
<a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html#getTightestCommonType-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-"><code>getTightestCommonType(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType)</code></a> is that we allow
some precision loss when widening decimal to fractional, or promote to string type.</div>
</li>
</ul>
<a name="getWiderTypeFor-java.util.List-boolean-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getWiderTypeFor</h4>
<pre><a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;getWiderTypeFor(<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;typeList,
boolean&nbsp;stringPromotion)</pre>
<div class="block">Similar to <a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html#getWiderTypeForTwo-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-boolean-"><code>getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean)</code></a>, but can handle
sequence types. <a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html#getWiderTypeForTwo-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-boolean-"><code>getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean)</code></a> doesn't satisfy the associative law,
i.e. (a op b) op c may not equal to a op (b op c). This is only a problem for STRING or
nested STRING in collection type like ARRAY. Excluding these types,
<a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html#getWiderTypeForTwo-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-boolean-"><code>getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean)</code></a> satisfies the associative law. For instance,
(DATE, INTEGER, VARCHAR) should have VARCHAR as the wider common type.</div>
</li>
</ul>
<a name="getWiderTypeForDecimal-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getWiderTypeForDecimal</h4>
<pre><a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;getWiderTypeForDecimal(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</pre>
<div class="block">Finds a wider type when one or both types are DECIMAL type.
<p>If the wider decimal type's precision/scale exceeds system limitation,
this rule will truncate the decimal type to the max precision/scale.
For DECIMAL and fractional types, returns DECIMAL type
that has the higher precision of the two.
<p>The default implementation depends on the max precision/scale of the type system,
you can override it based on the specific system requirement in
<a href="../../../../../../org/apache/calcite/rel/type/RelDataTypeSystem.html" title="interface in org.apache.calcite.rel.type"><code>RelDataTypeSystem</code></a>.</div>
</li>
</ul>
<a name="commonTypeForBinaryComparison-org.apache.calcite.rel.type.RelDataType-org.apache.calcite.rel.type.RelDataType-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>commonTypeForBinaryComparison</h4>
<pre><a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;commonTypeForBinaryComparison(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</pre>
<div class="block">Determines common type for a comparison operator whose operands are STRING
type and the other (non STRING) type.</div>
</li>
</ul>
<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>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 ith column type to target type, mainly used for set
operations like UNION, INTERSECT and EXCEPT.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>scope</code> - Scope to query</dd>
<dd><code>query</code> - SqlNode which have children nodes as columns</dd>
<dd><code>columnIndex</code> - Target column index</dd>
<dd><code>targetType</code> - Target type to cast to</dd>
</dl>
</li>
</ul>
<a name="inOperationCoercion-org.apache.calcite.sql.SqlCallBinding-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>inOperationCoercion</h4>
<pre>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">Handles type coercion for IN operation with or without sub-query.
<p>See <a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html" title="class in org.apache.calcite.sql.validate.implicit"><code>TypeCoercionImpl</code></a> for default strategies.</div>
</li>
</ul>
<a name="binaryArithmeticCoercion-org.apache.calcite.sql.SqlCallBinding-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binaryArithmeticCoercion</h4>
<pre>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 operand of binary arithmetic expressions to Numeric type.</div>
</li>
</ul>
<a name="binaryComparisonCoercion-org.apache.calcite.sql.SqlCallBinding-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binaryComparisonCoercion</h4>
<pre>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.</div>
</li>
</ul>
<a name="caseWhenCoercion-org.apache.calcite.sql.SqlCallBinding-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>caseWhenCoercion</h4>
<pre>boolean&nbsp;caseWhenCoercion(<a href="../../../../../../org/apache/calcite/sql/SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a>&nbsp;binding)</pre>
<div class="block">Coerces CASE WHEN statement branches to one common type.
<p>Rules: Find common type for all the then operands and else operands,
then try to coerce the then/else operands to the type if needed.</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>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">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>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">Non built-in functions (UDFs) type coercion, compare the types of arguments
with rules:
<ol>
<li>Named param: find the desired type by the passed in operand's name
<li>Non-named param: find the desired type by formal parameter ordinal
</ol>
<p>Try to make type coercion only if the desired type is found.</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>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">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/AbstractTypeCoercion.html" title="class 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/TypeCoercionFactory.html" title="interface 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/TypeCoercion.html" target="_top">Frames</a></li>
<li><a href="TypeCoercion.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>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&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>