blob: 2e64a4a386bdf8b45e116133f011a5a1bb2e12d2 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="zh">
<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","所有方法"],2:["t2","实例方法"],4:["t3","抽象方法"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>您的浏览器已禁用 JavaScript。</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="跳过导航链接">跳过导航链接</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="导航">
<li><a href="../../../../../../overview-summary.html">概览</a></li>
<li><a href="package-summary.html">程序包</a></li>
<li class="navBarCell1Rev"></li>
<li><a href="package-tree.html"></a></li>
<li><a href="../../../../../../deprecated-list.html">已过时</a></li>
<li><a href="../../../../../../index-all.html">索引</a></li>
<li><a href="../../../../../../help-doc.html">帮助</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="org.apache.calcite.sql.validate.implicit中的类"><span class="typeNameLink">上一个类</span></a></li>
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html" title="org.apache.calcite.sql.validate.implicit中的类"><span class="typeNameLink">下一个类</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/calcite/sql/validate/implicit/TypeCoercion.html" target="_top">框架</a></li>
<li><a href="TypeCoercion.html" target="_top">无框架</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses-noframe.html">所有类</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>概要:&nbsp;</li>
<li>嵌套&nbsp;|&nbsp;</li>
<li>字段&nbsp;|&nbsp;</li>
<li>构造器&nbsp;|&nbsp;</li>
<li><a href="#method.summary">方法</a></li>
</ul>
<ul class="subNavList">
<li>详细资料:&nbsp;</li>
<li>字段&nbsp;|&nbsp;</li>
<li>构造器&nbsp;|&nbsp;</li>
<li><a href="#method.detail">方法</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="接口 TypeCoercion" class="title">接口 TypeCoercion</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>所有已知实现类:</dt>
<dd><a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html" title="org.apache.calcite.sql.validate.implicit中的类">AbstractTypeCoercion</a>, <a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html" title="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>方法概要</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="方法概要表, 列表方法和解释">
<caption><span id="t0" class="activeTableTab"><span>所有方法</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">实例方法</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">抽象方法</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">限定符和类型</th>
<th class="colLast" scope="col">方法和说明</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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</code>
<div class="block">Coerce 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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</code>
<div class="block">Coerce 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="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="java.util中的类或接口">List</a>&lt;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="java.util中的类或接口">List</a>&lt;<a href="../../../../../../org/apache/calcite/sql/type/SqlTypeFamily.html" title="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="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="org.apache.calcite.sql.type中的类"><code>FamilyOperandTypeChecker</code></a>.</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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</code>
<div class="block">Coerce 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="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="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="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="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="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="java.util中的类或接口">List</a>&lt;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="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="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="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="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="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="org.apache.calcite.sql.validate中的接口">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;sourceRowType,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;targetRowType,
<a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="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="org.apache.calcite.sql.validate中的接口">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="org.apache.calcite.sql中的类">SqlNode</a>&nbsp;query,
int&nbsp;columnIndex,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="org.apache.calcite.sql.validate中的接口">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/sql/SqlCall.html" title="org.apache.calcite.sql中的类">SqlCall</a>&nbsp;call,
<a href="../../../../../../org/apache/calcite/sql/SqlFunction.html" title="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
Try to make type coercion only of the desired type is found.</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>方法详细资料</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="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;getTightestCommonType(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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">返回:</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="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;getWiderTypeForTwo(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="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="java.util中的类或接口">List</a>&lt;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;getWiderTypeForDecimal(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="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="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;commonTypeForBinaryComparison(<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;type1,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="org.apache.calcite.sql.validate中的接口">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="org.apache.calcite.sql中的类">SqlNode</a>&nbsp;query,
int&nbsp;columnIndex,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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">参数:</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>
<dt><span class="returnLabel">返回:</span></dt>
<dd>true if we add any cast in successfully</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="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="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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</pre>
<div class="block">Coerce 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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</pre>
<div class="block">Coerce 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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</pre>
<div class="block">Coerce 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="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="java.util中的类或接口">List</a>&lt;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="java.util中的类或接口">List</a>&lt;<a href="../../../../../../org/apache/calcite/sql/type/SqlTypeFamily.html" title="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="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="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="org.apache.calcite.sql.type中的类"><code>FamilyOperandTypeChecker</code></a>s are
subsumed in a
<a href="../../../../../../org/apache/calcite/sql/type/CompositeOperandTypeChecker.html" title="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">参数:</span></dt>
<dd><code>binding</code> - Call binding</dd>
<dd><code>operandTypes</code> - Types of the operands passed in</dd>
<dd><code>expectedFamilies</code> - Expected SqlTypeFamily list by user specified</dd>
<dt><span class="returnLabel">返回:</span></dt>
<dd>true if we successfully do any implicit cast</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="org.apache.calcite.sql.validate中的接口">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/sql/SqlCall.html" title="org.apache.calcite.sql中的类">SqlCall</a>&nbsp;call,
<a href="../../../../../../org/apache/calcite/sql/SqlFunction.html" title="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 of the desired type is found.</div>
<dl>
<dt><span class="returnLabel">返回:</span></dt>
<dd>true if any operands is coerced</dd>
</dl>
</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="org.apache.calcite.sql.validate中的接口">SqlValidatorScope</a>&nbsp;scope,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;sourceRowType,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;targetRowType,
<a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="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">参数:</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>
<dt><span class="returnLabel">返回:</span></dt>
<dd>True if any type coercion happens</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="跳过导航链接">跳过导航链接</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="导航">
<li><a href="../../../../../../overview-summary.html">概览</a></li>
<li><a href="package-summary.html">程序包</a></li>
<li class="navBarCell1Rev"></li>
<li><a href="package-tree.html"></a></li>
<li><a href="../../../../../../deprecated-list.html">已过时</a></li>
<li><a href="../../../../../../index-all.html">索引</a></li>
<li><a href="../../../../../../help-doc.html">帮助</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="org.apache.calcite.sql.validate.implicit中的类"><span class="typeNameLink">上一个类</span></a></li>
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html" title="org.apache.calcite.sql.validate.implicit中的类"><span class="typeNameLink">下一个类</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/calcite/sql/validate/implicit/TypeCoercion.html" target="_top">框架</a></li>
<li><a href="TypeCoercion.html" target="_top">无框架</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses-noframe.html">所有类</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>概要:&nbsp;</li>
<li>嵌套&nbsp;|&nbsp;</li>
<li>字段&nbsp;|&nbsp;</li>
<li>构造器&nbsp;|&nbsp;</li>
<li><a href="#method.summary">方法</a></li>
</ul>
<ul class="subNavList">
<li>详细资料:&nbsp;</li>
<li>字段&nbsp;|&nbsp;</li>
<li>构造器&nbsp;|&nbsp;</li>
<li><a href="#method.detail">方法</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>