| <!DOCTYPE HTML> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (17) --> |
| <title>TypeCoercion (Apache Calcite API)</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <meta name="description" content="declaration: package: org.apache.calcite.sql.validate.implicit, interface: TypeCoercion"> |
| <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.min.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../../../../jquery-ui.overrides.css" title="Style"> |
| <script type="text/javascript" src="../../../../../../script.js"></script> |
| <script type="text/javascript" src="../../../../../../script-dir/jquery-3.5.1.min.js"></script> |
| <script type="text/javascript" src="../../../../../../script-dir/jquery-ui.min.js"></script> |
| </head> |
| <body class="class-declaration-page"> |
| <script type="text/javascript">var evenRowColor = "even-row-color"; |
| var oddRowColor = "odd-row-color"; |
| var tableTab = "table-tab"; |
| var activeTableTab = "active-table-tab"; |
| var pathtoroot = "../../../../../../"; |
| loadScripts(document, 'script');</script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <div class="flex-box"> |
| <header role="banner" class="flex-header"> |
| <nav role="navigation"> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="top-nav" id="navbar-top"> |
| <div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div> |
| <div class="about-language"><b>Apache Calcite</b></div> |
| <ul id="navbar-top-firstrow" class="nav-list" title="Navigation"> |
| <li><a href="../../../../../../index.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="nav-bar-cell1-rev">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#class">Help</a></li> |
| </ul> |
| </div> |
| <div class="sub-nav"> |
| <div> |
| <ul class="sub-nav-list"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method-summary">Method</a></li> |
| </ul> |
| <ul class="sub-nav-list"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method-detail">Method</a></li> |
| </ul> |
| </div> |
| <div class="nav-list-search"><label for="search-input">SEARCH:</label> |
| <input type="text" id="search-input" value="search" disabled="disabled"> |
| <input type="reset" id="reset-button" value="reset" disabled="disabled"> |
| </div> |
| </div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <span class="skip-nav" id="skip-navbar-top"></span></nav> |
| </header> |
| <div class="flex-content"> |
| <main role="main"> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="sub-title"><span class="package-label-in-type">Package</span> <a href="package-summary.html">org.apache.calcite.sql.validate.implicit</a></div> |
| <h1 title="Interface TypeCoercion" class="title">Interface TypeCoercion</h1> |
| </div> |
| <section class="class-description" id="class-description"> |
| <dl class="notes"> |
| <dt>All Known Implementing Classes:</dt> |
| <dd><code><a href="AbstractTypeCoercion.html" title="class in org.apache.calcite.sql.validate.implicit">AbstractTypeCoercion</a></code>, <code><a href="TypeCoercionImpl.html" title="class in org.apache.calcite.sql.validate.implicit">TypeCoercionImpl</a></code></dd> |
| </dl> |
| <hr> |
| <div class="type-signature"><span class="modifiers">public interface </span><span class="element-name type-name-label">TypeCoercion</span></div> |
| <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> |
| </section> |
| <section class="summary"> |
| <ul class="summary-list"> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <li> |
| <section class="method-summary" id="method-summary"> |
| <h2>Method Summary</h2> |
| <div id="method-summary-table"> |
| <div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab3" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab3', 3)" class="table-tab">Abstract Methods</button></div> |
| <div id="method-summary-table.tabpanel" role="tabpanel"> |
| <div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0"> |
| <div class="table-header col-first">Modifier and Type</div> |
| <div class="table-header col-second">Method</div> |
| <div class="table-header col-last">Description</div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#binaryArithmeticCoercion(org.apache.calcite.sql.SqlCallBinding)" class="member-name-link">binaryArithmeticCoercion</a><wbr>(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Coerces operand of binary arithmetic expressions to Numeric type.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#binaryComparisonCoercion(org.apache.calcite.sql.SqlCallBinding)" class="member-name-link">binaryComparisonCoercion</a><wbr>(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Coerces operands in binary comparison expressions.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#builtinFunctionCoercion(org.apache.calcite.sql.SqlCallBinding,java.util.List,java.util.List)" class="member-name-link">builtinFunctionCoercion</a><wbr>(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding, |
| <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a><<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>> operandTypes, |
| <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a><<a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type">SqlTypeFamily</a>> expectedFamilies)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Type coercion with inferred type from passed in arguments 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> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#caseWhenCoercion(org.apache.calcite.sql.SqlCallBinding)" class="member-name-link">caseWhenCoercion</a><wbr>(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Coerces CASE WHEN statement branches to one common type.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)" class="member-name-link">commonTypeForBinaryComparison</a><wbr>(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type1, |
| @Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type2)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Determines common type for a comparison operator whose operands are STRING |
| type and the other (non STRING) type.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)" class="member-name-link">getTightestCommonType</a><wbr>(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type1, |
| @Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type2)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Case1: type widening with no precision loss.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getWiderTypeFor(java.util.List,boolean)" class="member-name-link">getWiderTypeFor</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a><<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>> typeList, |
| boolean stringPromotion)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <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> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)" class="member-name-link">getWiderTypeForDecimal</a><wbr>(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type1, |
| @Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type2)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Finds a wider type when one or both types are DECIMAL type.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)" class="member-name-link">getWiderTypeForTwo</a><wbr>(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type1, |
| @Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type2, |
| boolean stringPromotion)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Case2: type widening.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#inOperationCoercion(org.apache.calcite.sql.SqlCallBinding)" class="member-name-link">inOperationCoercion</a><wbr>(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Handles type coercion for IN operation with or without sub-query.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#querySourceCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.SqlNode)" class="member-name-link">querySourceCoercion</a><wbr>(@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a> scope, |
| <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> sourceRowType, |
| <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> targetRowType, |
| <a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a> query)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Coerces the source row expression to target type in an INSERT or UPDATE query.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#rowTypeCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)" class="member-name-link">rowTypeCoercion</a><wbr>(@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a> scope, |
| <a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a> query, |
| int columnIndex, |
| <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> targetType)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Widen a SqlNode ith column type to target type, mainly used for set |
| operations like UNION, INTERSECT and EXCEPT.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>boolean</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#userDefinedFunctionCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.sql.SqlFunction)" class="member-name-link">userDefinedFunctionCoercion</a><wbr>(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a> scope, |
| <a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a> call, |
| <a href="../../SqlFunction.html" title="class in org.apache.calcite.sql">SqlFunction</a> function)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Non built-in functions (UDFs) type coercion, compare the types of arguments |
| with rules: |
| |
| |
| Named param: find the desired type by the passed in operand's name |
| Non-named param: find the desired type by formal parameter ordinal |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <section class="details"> |
| <ul class="details-list"> |
| <!-- ============ METHOD DETAIL ========== --> |
| <li> |
| <section class="method-details" id="method-detail"> |
| <h2>Method Details</h2> |
| <ul class="member-list"> |
| <li> |
| <section class="detail" id="getTightestCommonType(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)"> |
| <h3>getTightestCommonType</h3> |
| <div class="member-signature"><span class="return-type">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span> <span class="element-name">getTightestCommonType</span><wbr><span class="parameters">(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type1, |
| @Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> 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 class="notes"> |
| <dt>Returns:</dt> |
| <dd>common type</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,boolean)"> |
| <h3>getWiderTypeForTwo</h3> |
| <div class="member-signature"><span class="return-type">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span> <span class="element-name">getWiderTypeForTwo</span><wbr><span class="parameters">(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type1, |
| @Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type2, |
| boolean 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 to string type.</div> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="getWiderTypeFor(java.util.List,boolean)"> |
| <h3>getWiderTypeFor</h3> |
| <div class="member-signature"><span class="return-type">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span> <span class="element-name">getWiderTypeFor</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a><<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>> typeList, |
| boolean 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 or |
| nested STRING 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> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)"> |
| <h3>getWiderTypeForDecimal</h3> |
| <div class="member-signature"><span class="return-type">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span> <span class="element-name">getWiderTypeForDecimal</span><wbr><span class="parameters">(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type1, |
| @Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type2)</span></div> |
| <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="../../../rel/type/RelDataTypeSystem.html" title="interface in org.apache.calcite.rel.type"><code>RelDataTypeSystem</code></a>.</div> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType)"> |
| <h3>commonTypeForBinaryComparison</h3> |
| <div class="member-signature"><span class="return-type">@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a></span> <span class="element-name">commonTypeForBinaryComparison</span><wbr><span class="parameters">(@Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type1, |
| @Nullable <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> type2)</span></div> |
| <div class="block">Determines common type for a comparison operator whose operands are STRING |
| type and the other (non STRING) type.</div> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="rowTypeCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlNode,int,org.apache.calcite.rel.type.RelDataType)"> |
| <h3>rowTypeCoercion</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">rowTypeCoercion</span><wbr><span class="parameters">(@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a> scope, |
| <a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a> query, |
| int columnIndex, |
| <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> targetType)</span></div> |
| <div class="block">Widen a SqlNode ith column type to target type, mainly used for set |
| operations like UNION, INTERSECT and EXCEPT.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>scope</code> - Scope to query</dd> |
| <dd><code>query</code> - SqlNode which have children nodes as columns</dd> |
| <dd><code>columnIndex</code> - Target column index</dd> |
| <dd><code>targetType</code> - Target type to cast to</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="inOperationCoercion(org.apache.calcite.sql.SqlCallBinding)"> |
| <h3>inOperationCoercion</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">inOperationCoercion</span><wbr><span class="parameters">(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding)</span></div> |
| <div class="block">Handles type coercion for IN operation with or without sub-query. |
| |
| <p>See <a href="TypeCoercionImpl.html" title="class in org.apache.calcite.sql.validate.implicit"><code>TypeCoercionImpl</code></a> for default strategies.</div> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="binaryArithmeticCoercion(org.apache.calcite.sql.SqlCallBinding)"> |
| <h3>binaryArithmeticCoercion</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">binaryArithmeticCoercion</span><wbr><span class="parameters">(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding)</span></div> |
| <div class="block">Coerces operand of binary arithmetic expressions to Numeric type.</div> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="binaryComparisonCoercion(org.apache.calcite.sql.SqlCallBinding)"> |
| <h3>binaryComparisonCoercion</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">binaryComparisonCoercion</span><wbr><span class="parameters">(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding)</span></div> |
| <div class="block">Coerces operands in binary comparison expressions.</div> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="caseWhenCoercion(org.apache.calcite.sql.SqlCallBinding)"> |
| <h3>caseWhenCoercion</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">caseWhenCoercion</span><wbr><span class="parameters">(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding)</span></div> |
| <div class="block">Coerces CASE WHEN statement branches to one common type. |
| |
| <p>Rules: Find common type for all the then operands and else operands, |
| then try to coerce the then/else operands to the type if needed.</div> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="builtinFunctionCoercion(org.apache.calcite.sql.SqlCallBinding,java.util.List,java.util.List)"> |
| <h3>builtinFunctionCoercion</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">builtinFunctionCoercion</span><wbr><span class="parameters">(<a href="../../SqlCallBinding.html" title="class in org.apache.calcite.sql">SqlCallBinding</a> binding, |
| <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a><<a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a>> operandTypes, |
| <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a><<a href="../../type/SqlTypeFamily.html" title="enum in org.apache.calcite.sql.type">SqlTypeFamily</a>> expectedFamilies)</span></div> |
| <div class="block">Type coercion with inferred type from passed in arguments 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 if desired type family is also |
| <a href="../../type/SqlTypeFamily.html#NUMERIC"><code>SqlTypeFamily.NUMERIC</code></a>. |
| |
| <p>If the <a href="../../type/FamilyOperandTypeChecker.html" title="class in org.apache.calcite.sql.type"><code>FamilyOperandTypeChecker</code></a>s are |
| subsumed in a |
| <a href="../../type/CompositeOperandTypeChecker.html" title="class in org.apache.calcite.sql.type"><code>CompositeOperandTypeChecker</code></a>, check them |
| based on their combination order. i.e. If we allow a NUMERIC_NUMERIC OR |
| STRING_NUMERIC family combination and are with arguments (op1: VARCHAR(20), op2: BOOLEAN), |
| try to coerce both op1 and op2 to NUMERIC if the type coercion rules allow it, |
| or else try to coerce op2 to NUMERIC and keep op1 the type as it is. |
| |
| <p>This is also very interrelated to the composition predicate for the |
| checkers: if the predicate is AND, we would fail fast if the first family |
| type coercion fails.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>binding</code> - Call binding</dd> |
| <dd><code>operandTypes</code> - Types of the operands passed in</dd> |
| <dd><code>expectedFamilies</code> - Expected SqlTypeFamily list by user specified</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="userDefinedFunctionCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.sql.SqlCall,org.apache.calcite.sql.SqlFunction)"> |
| <h3>userDefinedFunctionCoercion</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">userDefinedFunctionCoercion</span><wbr><span class="parameters">(<a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a> scope, |
| <a href="../../SqlCall.html" title="class in org.apache.calcite.sql">SqlCall</a> call, |
| <a href="../../SqlFunction.html" title="class in org.apache.calcite.sql">SqlFunction</a> function)</span></div> |
| <div class="block">Non built-in functions (UDFs) type coercion, compare the types of arguments |
| with rules: |
| |
| <ol> |
| <li>Named param: find the desired type by the passed in operand's name |
| <li>Non-named param: find the desired type by formal parameter ordinal |
| </ol> |
| |
| <p>Try to make type coercion only if the desired type is found.</div> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="querySourceCoercion(org.apache.calcite.sql.validate.SqlValidatorScope,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.rel.type.RelDataType,org.apache.calcite.sql.SqlNode)"> |
| <h3>querySourceCoercion</h3> |
| <div class="member-signature"><span class="return-type">boolean</span> <span class="element-name">querySourceCoercion</span><wbr><span class="parameters">(@Nullable <a href="../SqlValidatorScope.html" title="interface in org.apache.calcite.sql.validate">SqlValidatorScope</a> scope, |
| <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> sourceRowType, |
| <a href="../../../rel/type/RelDataType.html" title="interface in org.apache.calcite.rel.type">RelDataType</a> targetRowType, |
| <a href="../../SqlNode.html" title="class in org.apache.calcite.sql">SqlNode</a> query)</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 class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>scope</code> - Source scope</dd> |
| <dd><code>sourceRowType</code> - Source row type</dd> |
| <dd><code>targetRowType</code> - Target row type</dd> |
| <dd><code>query</code> - The query, either an INSERT or UPDATE</dd> |
| </dl> |
| </section> |
| </li> |
| </ul> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <!-- ========= END OF CLASS DATA ========= --> |
| </main> |
| <footer role="contentinfo"> |
| <hr> |
| <p class="legal-copy"><small>Copyright © 2012-2023 Apache Software Foundation. All Rights Reserved.</small></p> |
| </footer> |
| </div> |
| </div> |
| </body> |
| </html> |