blob: 46b387cf3dd5709d851370daceb7465202d5c874 [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>AbstractTypeCoercion (Apache Calcite calcite API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="declaration: package: org.apache.calcite.sql.validate.implicit, class: AbstractTypeCoercion">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../script-dir/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../../script-dir/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../../../script-dir/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../../../script-dir/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../../../script-dir/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../../../../../../script-dir/jquery-ui.js"></script>
</head>
<body class="class-declaration">
<script type="text/javascript">var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10,"i9":10,"i10":10,"i11":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../../../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flexBox">
<header role="banner" class="flexHeader">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><b>Apache Calcite</b></div>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&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><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<div class="navListSearch"><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="skipNav"><a id="skip.navbar.top">
<!-- -->
</a></div>
</nav>
</header>
<div class="flexContent">
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">org.apache.calcite.sql.validate.implicit</a></div>
<h1 title="Class AbstractTypeCoercion" class="title">Class AbstractTypeCoercion</h1>
</div>
<div class="contentContainer">
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">java.lang.Object</a>
<div class="inheritance">org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion</div>
</div>
<section class="description">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><code><a href="TypeCoercionImpl.html" title="class in org.apache.calcite.sql.validate.implicit">TypeCoercionImpl</a></code></dd>
</dl>
<hr>
<pre>public abstract class <span class="typeNameLabel">AbstractTypeCoercion</span>
extends <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a>
implements <a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></pre>
<div class="block">Base class for all the type coercion rules. If you want to have a custom type coercion rules,
inheriting this class is not necessary, but would have some convenient tool methods.
<p>We make tool methods: <a href="#coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,int,org.apache.calcite.rel.type.RelDataType)"><code>coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlCall, int, org.apache.calcite.rel.type.RelDataType)</code></a>, <a href="#coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNodeList,int,org.apache.calcite.rel.type.RelDataType)"><code>coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlNodeList, int, org.apache.calcite.rel.type.RelDataType)</code></a>,
<a href="#needToCast(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)"><code>needToCast(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlNode, org.apache.calcite.rel.type.RelDataType)</code></a>, <a href="#updateInferredType(org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)"><code>updateInferredType(org.apache.calcite.sql.SqlNode, org.apache.calcite.rel.type.RelDataType)</code></a>, <a href="#updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)"><code>updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlNode, int, org.apache.calcite.rel.type.RelDataType)</code></a>
all overridable by derived classes, you can define system specific type coercion logic.
<p>Caution that these methods may modify the <a href="../../SqlNode.html" title="class in org.apache.calcite.sql"><code>SqlNode</code></a> tree, you should know what the
effect is when using these methods to customize your type coercion rules.
<p>This class also defines the default implementation of the type widening strategies, see
<a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit"><code>TypeCoercion</code></a> doc and methods: <a href="#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>, <a href="#getWiderTypeFor(java.util.List,boolean)"><code>getWiderTypeFor(java.util.List&lt;org.apache.calcite.rel.type.RelDataType&gt;, boolean)</code></a>,
<a href="#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>, <a href="#getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)"><code>getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType)</code></a>,
<a href="#commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)"><code>commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType)</code></a> for the detail strategies.</div>
</section>
<section class="summary">
<ul class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<li class="blockList">
<section class="fieldSummary"><a id="field.summary">
<!-- -->
</a>
<h2>Field Summary</h2>
<div class="memberSummary">
<table>
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<thead>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Field</th>
<th class="colLast" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>protected <a href="../../../rel/type/RelDataTypeFactory.html" title="interface in org.apache.calcite.rel.type">RelDataTypeFactory</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#factory">factory</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>protected <a href="../SqlValidator.html" title="interface in org.apache.calcite.sql.validate">SqlValidator</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#validator">validator</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li class="blockList">
<section class="methodSummary"><a id="method.summary">
<!-- -->
</a>
<h2>Method Summary</h2>
<div class="memberSummary">
<div role="tablist" aria-orientation="horizontal"><button role="tab" aria-selected="true" aria-controls="memberSummary_tabpanel" tabindex="0" onkeydown="switchTab(event)" id="t0" class="activeTableTab">All Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t2" class="tableTab" onclick="show(2);">Instance Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t4" class="tableTab" onclick="show(8);">Concrete Methods</button></div>
<div id="memberSummary_tabpanel" role="tabpanel">
<table aria-labelledby="t0">
<thead>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr class="altColor" id="i0">
<td class="colFirst"><code>protected boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNodeList,int,org.apache.calcite.rel.type.RelDataType)">coerceColumnType</a></span>&#8203;(@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNodeList.html" title="class in org.apache.calcite.sql">SqlNodeList</a>&nbsp;nodeList,
int&nbsp;index,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetType)</code></th>
<td class="colLast">
<div class="block">Cast column at index <code>index</code> to target type.</div>
</td>
</tr>
<tr class="rowColor" id="i1">
<td class="colFirst"><code>protected boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#coerceOperandsType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.rel.type.RelDataType)">coerceOperandsType</a></span>&#8203;(@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;commonType)</code></th>
<td class="colLast">
<div class="block">Coerce all the operands to <code>commonType</code>.</div>
</td>
</tr>
<tr class="altColor" id="i2">
<td class="colFirst"><code>protected boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,int,org.apache.calcite.rel.type.RelDataType)">coerceOperandType</a></span>&#8203;(@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
int&nbsp;index,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetType)</code></th>
<td class="colLast">
<div class="block">Cast operand at index <code>index</code> to target type.</div>
</td>
</tr>
<tr class="rowColor" id="i3">
<td class="colFirst"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">commonTypeForBinaryComparison</a></span>&#8203;(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</code></th>
<td class="colLast">
<div class="block">Determines common type for a comparison operator when one operand is String type and the
other is not.</div>
</td>
</tr>
<tr class="altColor" id="i4">
<td class="colFirst"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getTightestCommonType</a></span>&#8203;(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</code></th>
<td class="colLast">
<div class="block">Case1: type widening with no precision loss.</div>
</td>
</tr>
<tr class="rowColor" id="i5">
<td class="colFirst"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getWiderTypeFor(java.util.List,boolean)">getWiderTypeFor</a></span>&#8203;(<a href="https://docs.oracle.com/javase/9/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util" class="externalLink">List</a>&lt;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&gt;&nbsp;typeList,
boolean&nbsp;stringPromotion)</code></th>
<td class="colLast">
<div class="block">Similar to <a href="#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 class="altColor" id="i6">
<td class="colFirst"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getWiderTypeForDecimal</a></span>&#8203;(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</code></th>
<td class="colLast">
<div class="block">Finds a wider type when one or both types are decimal type.</div>
</td>
</tr>
<tr class="rowColor" id="i7">
<td class="colFirst"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)">getWiderTypeForTwo</a></span>&#8203;(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2,
boolean&nbsp;stringPromotion)</code></th>
<td class="colLast">
<div class="block">Case2: type widening.</div>
</td>
</tr>
<tr class="altColor" id="i8">
<td class="colFirst"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#implicitCast(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.type.SqlTypeFamily)">implicitCast</a></span>&#8203;(<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;in,
<a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type">SqlTypeFamily</a>&nbsp;expected)</code></th>
<td class="colLast">
<div class="block">Type coercion based on the inferred type from passed in operand
and the <a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type"><code>SqlTypeFamily</code></a> defined in the checkers,
e.g.</div>
</td>
</tr>
<tr class="rowColor" id="i9">
<td class="colFirst"><code>protected boolean</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#needToCast(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">needToCast</a></span>&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;node,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;toType)</code></th>
<td class="colLast">
<div class="block">Decide if a SqlNode should be casted to target type, derived class
can override this strategy.</div>
</td>
</tr>
<tr class="altColor" id="i10">
<td class="colFirst"><code>protected void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)">updateInferredColumnType</a></span>&#8203;(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;query,
int&nbsp;columnIndex,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;desiredType)</code></th>
<td class="colLast">
<div class="block">Update inferred row type for a query, i.e.</div>
</td>
</tr>
<tr class="rowColor" id="i11">
<td class="colFirst"><code>protected void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#updateInferredType(org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">updateInferredType</a></span>&#8203;(<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;node,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type)</code></th>
<td class="colLast">
<div class="block">Update inferred type for a SqlNode.</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="inheritedList">
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang" class="externalLink">Object</a></h3>
<a id="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a><code><a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang" class="externalLink">clone</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang" class="externalLink">equals</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang" class="externalLink">finalize</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang" class="externalLink">getClass</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang" class="externalLink">hashCode</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang" class="externalLink">notify</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang" class="externalLink">notifyAll</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang" class="externalLink">toString</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang" class="externalLink">wait</a>, <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html?is-external=true#wait(long,int)" title="class or interface in java.lang" class="externalLink">wait</a></code></div>
<div class="inheritedList">
<h3>Methods inherited from interface&nbsp;org.apache.calcite.sql.validate.implicit.<a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></h3>
<a id="methods.inherited.from.class.org.apache.calcite.sql.validate.implicit.TypeCoercion">
<!-- -->
</a><code><a href="TypeCoercion.html#binaryArithmeticCoercion(org.apache.calcite.sql.SqlCallBinding)">binaryArithmeticCoercion</a>, <a href="TypeCoercion.html#binaryComparisonCoercion(org.apache.calcite.sql.SqlCallBinding)">binaryComparisonCoercion</a>, <a href="TypeCoercion.html#builtinFunctionCoercion(org.apache.calcite.sql.SqlCallBinding,java.util.List,java.util.List)">builtinFunctionCoercion</a>, <a href="TypeCoercion.html#caseWhenCoercion(org.apache.calcite.sql.SqlCallBinding)">caseWhenCoercion</a>, <a href="TypeCoercion.html#inOperationCoercion(org.apache.calcite.sql.SqlCallBinding)">inOperationCoercion</a>, <a href="TypeCoercion.html#querySourceCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.SqlNode)">querySourceCoercion</a>, <a href="TypeCoercion.html#rowTypeCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)">rowTypeCoercion</a>, <a href="TypeCoercion.html#userDefinedFunctionCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.sql.SqlFunction)">userDefinedFunctionCoercion</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<li class="blockList">
<section class="fieldDetails"><a id="field.detail">
<!-- -->
</a>
<h2>Field Details</h2>
<ul class="blockList">
<li class="blockList">
<section class="detail">
<h3><a id="validator">validator</a></h3>
<div class="memberSignature"><span class="modifiers">protected</span>&nbsp;<span class="returnType"><a href="../SqlValidator.html" title="interface in org.apache.calcite.sql.validate">SqlValidator</a></span>&nbsp;<span class="memberName">validator</span></div>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="factory">factory</a></h3>
<div class="memberSignature"><span class="modifiers">protected</span>&nbsp;<span class="returnType"><a href="../../../rel/type/RelDataTypeFactory.html" title="interface in org.apache.calcite.rel.type">RelDataTypeFactory</a></span>&nbsp;<span class="memberName">factory</span></div>
</section>
</li>
</ul>
</section>
</li>
<!-- ============ METHOD DETAIL ========== -->
<li class="blockList">
<section class="methodDetails"><a id="method.detail">
<!-- -->
</a>
<h2>Method Details</h2>
<ul class="blockList">
<li class="blockList">
<section class="detail">
<h3><a id="coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,int,org.apache.calcite.rel.type.RelDataType)">coerceOperandType</a></h3>
<div class="memberSignature"><span class="modifiers">protected</span>&nbsp;<span class="returnType">boolean</span>&nbsp;<span class="memberName">coerceOperandType</span>&#8203;(<span class="arguments">@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
int&nbsp;index,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetType)</span></div>
<div class="block">Cast operand at index <code>index</code> to target type.
we do this base on the fact that validate happens before type coercion.</div>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="coerceOperandsType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.rel.type.RelDataType)">coerceOperandsType</a></h3>
<div class="memberSignature"><span class="modifiers">protected</span>&nbsp;<span class="returnType">boolean</span>&nbsp;<span class="memberName">coerceOperandsType</span>&#8203;(<span class="arguments">@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a>&nbsp;call,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;commonType)</span></div>
<div class="block">Coerce all the operands to <code>commonType</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>scope</code> - Validator scope</dd>
<dd><code>call</code> - the call</dd>
<dd><code>commonType</code> - common type to coerce to</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNodeList,int,org.apache.calcite.rel.type.RelDataType)">coerceColumnType</a></h3>
<div class="memberSignature"><span class="modifiers">protected</span>&nbsp;<span class="returnType">boolean</span>&nbsp;<span class="memberName">coerceColumnType</span>&#8203;(<span class="arguments">@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNodeList.html" title="class in org.apache.calcite.sql">SqlNodeList</a>&nbsp;nodeList,
int&nbsp;index,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;targetType)</span></div>
<div class="block">Cast column at index <code>index</code> to target type.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>scope</code> - Validator scope for the node list</dd>
<dd><code>nodeList</code> - Column node list</dd>
<dd><code>index</code> - Index of column</dd>
<dd><code>targetType</code> - Target type to cast to</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="needToCast(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">needToCast</a></h3>
<div class="memberSignature"><span class="modifiers">protected</span>&nbsp;<span class="returnType">boolean</span>&nbsp;<span class="memberName">needToCast</span>&#8203;(<span class="arguments"><a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;node,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;toType)</span></div>
<div class="block">Decide if a SqlNode should be casted to target type, derived class
can override this strategy.</div>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="updateInferredType(org.apache.calcite.sql.SqlNode,org.apache.calcite.rel.type.RelDataType)">updateInferredType</a></h3>
<div class="memberSignature"><span class="modifiers">protected</span>&nbsp;<span class="returnType">void</span>&nbsp;<span class="memberName">updateInferredType</span>&#8203;(<span class="arguments"><a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;node,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type)</span></div>
<div class="block">Update inferred type for a SqlNode.</div>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)">updateInferredColumnType</a></h3>
<div class="memberSignature"><span class="modifiers">protected</span>&nbsp;<span class="returnType">void</span>&nbsp;<span class="memberName">updateInferredColumnType</span>&#8203;(<span class="arguments"><a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a>&nbsp;scope,
<a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a>&nbsp;query,
int&nbsp;columnIndex,
<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;desiredType)</span></div>
<div class="block">Update inferred row type for a query, i.e. SqlCall that returns struct type
or SqlSelect.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>scope</code> - Validator scope</dd>
<dd><code>query</code> - Node to inferred type</dd>
<dd><code>columnIndex</code> - Column index to update</dd>
<dd><code>desiredType</code> - Desired column type</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getTightestCommonType</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="returnType">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span>&nbsp;<span class="memberName">getTightestCommonType</span>&#8203;(<span class="arguments">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</span></div>
<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="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getTightestCommonType</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>tightest common type, i.e. INTEGER + DECIMAL(10, 2) returns DECIMAL(10, 2)</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">commonTypeForBinaryComparison</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="returnType">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span>&nbsp;<span class="memberName">commonTypeForBinaryComparison</span>&#8203;(<span class="arguments">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</span></div>
<div class="block">Determines common type for a comparison operator when one operand is String type and the
other is not. For date + timestamp operands, use timestamp as common type,
i.e. Timestamp(2017-01-01 00:00 ...) &gt; Date(2018) evaluates to be false.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">commonTypeForBinaryComparison</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)">getWiderTypeForTwo</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="returnType">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span>&nbsp;<span class="memberName">getWiderTypeForTwo</span>&#8203;(<span class="arguments">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2,
boolean&nbsp;stringPromotion)</span></div>
<div class="block">Case2: type widening. The main difference with <a href="#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 fractional to string type.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)">getWiderTypeForTwo</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getWiderTypeForDecimal</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="returnType">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span>&nbsp;<span class="memberName">getWiderTypeForDecimal</span>&#8203;(<span class="arguments">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type1,
@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;type2)</span></div>
<div class="block">Finds a wider type when one or both types are decimal type.
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 a decimal type
which 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="../../../rel/type/RelDataTypeSystem.html" title="interface in org.apache.calcite.rel.type"><code>RelDataTypeSystem</code></a>.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)">getWiderTypeForDecimal</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getWiderTypeFor(java.util.List,boolean)">getWiderTypeFor</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="returnType">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span>&nbsp;<span class="memberName">getWiderTypeFor</span>&#8203;(<span class="arguments"><a href="https://docs.oracle.com/javase/9/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util" class="externalLink">List</a>&lt;<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&gt;&nbsp;typeList,
boolean&nbsp;stringPromotion)</span></div>
<div class="block">Similar to <a href="#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="#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 type or
nested STRING type in collection type like ARRAY. Excluding these types,
<a href="#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>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="TypeCoercion.html#getWiderTypeFor(java.util.List,boolean)">getWiderTypeFor</a></code>&nbsp;in interface&nbsp;<code><a href="TypeCoercion.html" title="interface in org.apache.calcite.sql.validate.implicit">TypeCoercion</a></code></dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="implicitCast(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.type.SqlTypeFamily)">implicitCast</a></h3>
<div class="memberSignature"><span class="modifiers">public</span>&nbsp;<span class="returnType">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span>&nbsp;<span class="memberName">implicitCast</span>&#8203;(<span class="arguments"><a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>&nbsp;in,
<a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type">SqlTypeFamily</a>&nbsp;expected)</span></div>
<div class="block">Type coercion based on the inferred type from passed in operand
and the <a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type"><code>SqlTypeFamily</code></a> defined in the checkers,
e.g. the <a href="../../type/FamilyOperandTypeChecker.html" title="class in org.apache.calcite.sql.type"><code>FamilyOperandTypeChecker</code></a>.
<p>Caution that we do not cast from NUMERIC to NUMERIC.
See <a href="https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing">CalciteImplicitCasts</a>
for the details.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>in</code> - Inferred operand type</dd>
<dd><code>expected</code> - Expected <a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type"><code>SqlTypeFamily</code></a> of registered SqlFunction</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>common type of implicit cast, null if we do not find any</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
</div>
<!-- ========= END OF CLASS DATA ========= -->
</main>
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><b>Apache Calcite</b></div>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&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><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small>Copyright &copy; 2012-2021 Apache Software Foundation. All Rights Reserved.</small></p>
</footer>
</div>
</div>
</body>
</html>