blob: fc4da52ebde70f474f4e72ce8a4e4bde78cc6ec8 [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>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","所有方法"],2:["t2","实例方法"],8:["t4","具体方法"]};
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/TypeCoercion.html" title="org.apache.calcite.sql.validate.implicit中的接口"><span class="typeNameLink">上一个类</span></a></li>
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercions.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/TypeCoercionImpl.html" target="_top">框架</a></li>
<li><a href="TypeCoercionImpl.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><a href="#fields.inherited.from.class.org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion">字段</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">构造器</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">方法</a></li>
</ul>
<ul class="subNavList">
<li>详细资料:&nbsp;</li>
<li>字段&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">构造器</a>&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="类 TypeCoercionImpl" class="title">类 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="java.lang中的类或接口">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html" title="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>所有已实现的接口:</dt>
<dd><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html" title="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="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>字段概要</h3>
<ul class="blockList">
<li class="blockList"><a name="fields.inherited.from.class.org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion">
<!-- -->
</a>
<h3>从类继承的字段&nbsp;org.apache.calcite.sql.validate.implicit.<a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html" title="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>构造器概要</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="构造器概要表, 列表构造器和解释">
<caption><span>构造器</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">构造器和说明</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.sql.validate.SqlValidator-">TypeCoercionImpl</a></span>(<a href="../../../../../../org/apache/calcite/sql/validate/SqlValidator.html" title="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>方法概要</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="t4" class="tableTab"><span><a href="javascript:show(8);">具体方法</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/TypeCoercionImpl.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 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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</code>
<div class="block">Coerce 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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;right)</code>
<div class="block">Cast "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="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="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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;callBinding)</code>
<div class="block">Case when and COALESCE type coercion, collect all the branches types including then
operands and else operands to find a common type, then cast the operands to the common type
if it is needed.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>protected <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/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="java.util中的类或接口">List</a>&lt;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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
make 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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</code>
<div class="block">STRATEGIES
With(Without) sub-query:
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.</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="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="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="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's field type to target 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="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">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>从类继承的方法&nbsp;org.apache.calcite.sql.validate.implicit.<a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html" title="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>从类继承的方法&nbsp;java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="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="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="java.lang中的类或接口">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="java.lang中的类或接口">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="java.lang中的类或接口">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="java.lang中的类或接口">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="java.lang中的类或接口">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="java.lang中的类或接口">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="java.lang中的类或接口">toString</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="java.lang中的类或接口">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="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="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>构造器详细资料</h3>
<a name="TypeCoercionImpl-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/sql/validate/SqlValidator.html" title="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>方法详细资料</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="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's field type to target type,
mainly used for set operations like UNION, INTERSECT and EXCEPT.
<p>Rules:
<pre>
type1, type2 type3 select a, b, c from t1
\ \ \
type4 type5 type6 UNION
/ / /
type7 type8 type9 select d, e, f from t2
</pre>
For struct type (type1, type2, type3) union type (type4, type5, type6),
infer the first result column type type7 as the wider type of type1 and type4,
the second column type as the wider type of type2 and type5 and so on.</div>
<dl>
<dt><span class="paramLabel">参数:</span></dt>
<dd><code>scope</code> - validator scope</dd>
<dd><code>query</code> - query node to update the field type for</dd>
<dd><code>columnIndex</code> - target column index</dd>
<dd><code>targetType</code> - target type to cast to</dd>
<dt><span class="returnLabel">返回:</span></dt>
<dd>true if any type coercion actually happens</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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</pre>
<div class="block">Coerce 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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding)</pre>
<div class="block">Coerce 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="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="java.util中的类或接口">List</a>&lt;<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;right)</pre>
<div class="block">Datetime and STRING equality: cast STRING type to datetime type, SqlToRelConverter already
make the conversion but we still keep this interface overridable
so user can have their custom implementation.</div>
</li>
</ul>
<a 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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;binding,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;left,
<a href="../../../../../../org/apache/calcite/rel/type/RelDataType.html" title="org.apache.calcite.rel.type中的接口">RelDataType</a>&nbsp;right)</pre>
<div class="block">Cast "BOOLEAN = NUMERIC" to "NUMERIC = NUMERIC". Expressions like 1=`expr` and
0=`expr` can be simplified to `expr` and `not expr`, but this better happens
in <a href="../../../../../../org/apache/calcite/rex/RexSimplify.html" title="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="org.apache.calcite.sql中的类">SqlCallBinding</a>&nbsp;callBinding)</pre>
<div class="block">Case when and COALESCE type coercion, collect all the branches types including then
operands and else operands to find a common type, then cast the operands to the common type
if it is needed.</div>
</li>
</ul>
<a 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="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="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"><span class="descfrmTypeLabel">从接口复制的说明:&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="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>public&nbsp;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">Type coercion for user defined functions(UDFs).</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>public&nbsp;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"><span class="descfrmTypeLabel">从接口复制的说明:&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">参数:</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/TypeCoercion.html" title="org.apache.calcite.sql.validate.implicit中的接口"><span class="typeNameLink">上一个类</span></a></li>
<li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercions.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/TypeCoercionImpl.html" target="_top">框架</a></li>
<li><a href="TypeCoercionImpl.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><a href="#fields.inherited.from.class.org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion">字段</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">构造器</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">方法</a></li>
</ul>
<ul class="subNavList">
<li>详细资料:&nbsp;</li>
<li>字段&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">构造器</a>&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>