| <!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>org.apache.calcite.sql.validate.implicit (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="org.apache.calcite.sql.validate.implicit (Apache Calcite calcite API)"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| </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 class="navBarCell1Rev">程序包</li> |
| <li>类</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/package-summary.html">上一个程序包</a></li> |
| <li><a href="../../../../../../org/apache/calcite/sql2rel/package-summary.html">下一个程序包</a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../index.html?org/apache/calcite/sql/validate/implicit/package-summary.html" target="_top">框架</a></li> |
| <li><a href="package-summary.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> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <div class="header"> |
| <h1 title="程序包" class="title">程序包 org.apache.calcite.sql.validate.implicit</h1> |
| <div class="docSummary"> |
| <div class="block">SQL Implicit Type Cast |
| |
| Work Flow |
| |
| This package contains rules for implicit type coercion, it works during |
| the process of SQL validation.</div> |
| </div> |
| <p>请参阅: <a href="#package.description">说明</a></p> |
| </div> |
| <div class="contentContainer"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="接口概要表, 列表接口和解释"> |
| <caption><span>接口概要</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">接口</th> |
| <th class="colLast" scope="col">说明</th> |
| </tr> |
| <tbody> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html" title="org.apache.calcite.sql.validate.implicit中的接口">TypeCoercion</a></td> |
| <td class="colLast"> |
| <div class="block">Default strategies to coerce differing types that participate in |
| operations into compatible ones.</div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </li> |
| <li class="blockList"> |
| <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="类概要表, 列表类和解释"> |
| <caption><span>类概要</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">类</th> |
| <th class="colLast" scope="col">说明</th> |
| </tr> |
| <tbody> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.html" title="org.apache.calcite.sql.validate.implicit中的类">AbstractTypeCoercion</a></td> |
| <td class="colLast"> |
| <div class="block">Base class for all the type coercion rules.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.html" title="org.apache.calcite.sql.validate.implicit中的类">TypeCoercionImpl</a></td> |
| <td class="colLast"> |
| <div class="block">Default implementation of Calcite implicit type cast.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercions.html" title="org.apache.calcite.sql.validate.implicit中的类">TypeCoercions</a></td> |
| <td class="colLast"> |
| <div class="block">Factory class for type coercion instantiation of different sql dialects.</div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </li> |
| </ul> |
| <a name="package.description"> |
| <!-- --> |
| </a> |
| <h2 title="程序包org.apache.calcite.sql.validate.implicit的说明">程序包org.apache.calcite.sql.validate.implicit的说明</h2> |
| <div class="block"><h2>SQL Implicit Type Cast</h2> |
| |
| <h3>Work Flow</h3> |
| |
| <p>This package contains rules for implicit type coercion, it works during |
| the process of SQL validation. The transformation entrance are all kinds of |
| checkers. i.e. |
| <a href="../../../../../../org/apache/calcite/sql/type/AssignableOperandTypeChecker.html" title="org.apache.calcite.sql.type中的类"><code>AssignableOperandTypeChecker</code></a>, |
| <a href="../../../../../../org/apache/calcite/sql/type/ComparableOperandTypeChecker.html" title="org.apache.calcite.sql.type中的类"><code>ComparableOperandTypeChecker</code></a> |
| <a href="../../../../../../org/apache/calcite/sql/type/CompositeOperandTypeChecker.html" title="org.apache.calcite.sql.type中的类"><code>CompositeOperandTypeChecker</code></a>, |
| <a href="../../../../../../org/apache/calcite/sql/type/FamilyOperandTypeChecker.html" title="org.apache.calcite.sql.type中的类"><code>FamilyOperandTypeChecker</code></a>, |
| <a href="../../../../../../org/apache/calcite/sql/type/SameOperandTypeChecker.html" title="org.apache.calcite.sql.type中的类"><code>SameOperandTypeChecker</code></a>, |
| <a href="../../../../../../org/apache/calcite/sql/type/SetopOperandTypeChecker.html" title="org.apache.calcite.sql.type中的类"><code>SetopOperandTypeChecker</code></a>. |
| |
| <ul> |
| <li> |
| When user do validation for a <a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="org.apache.calcite.sql中的类"><code>SqlNode</code></a>, |
| and the type coercion is turned on(default), the validator will check the |
| operands/return types of all kinds of operators, if the validation passes through, |
| the validator will just cache the data type (say RelDataType) for the |
| <a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="org.apache.calcite.sql中的类"><code>SqlNode</code></a> it has validated;</li> |
| <li>If the validation fails, the validator will ask the |
| <a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html" title="org.apache.calcite.sql.validate.implicit中的接口"><code>TypeCoercion</code></a> about |
| if there can make implicit type coercion, if the coercion rules passed, the |
| <a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html" title="org.apache.calcite.sql.validate.implicit中的接口"><code>TypeCoercion</code></a> component |
| will replace the <a href="../../../../../../org/apache/calcite/sql/SqlNode.html" title="org.apache.calcite.sql中的类"><code>SqlNode</code></a> with a casted one, |
| (the node may be an operand of an operator or a column field of a selected row).</li> |
| <li><a href="../../../../../../org/apache/calcite/sql/validate/implicit/TypeCoercion.html" title="org.apache.calcite.sql.validate.implicit中的接口"><code>TypeCoercion</code></a> |
| will then update the inferred type for the casted node and |
| the containing operator/row column type.</li> |
| <li>If the coercion rule fails again, the validator will just throw |
| the exception as is before.</li> |
| </ul> |
| |
| <p>For some cases, although the validation passes, we still need the type coercion, e.g. for |
| expression 1 > '1', Calcite will just return false without type coercion, we do type coercion |
| eagerly here: the result expression would be transformed to "1 > cast('1' as int)" and |
| the result would be true. |
| |
| <h3>Conversion SQL Contexts</h3> |
| |
| <p>The supported conversion contexts are: |
| <a href="https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing">Conversion Expressions</a> |
| |
| <p>Strategies for Finding Common Type:</p> |
| <ul> |
| <li>If the operator has expected data types, just take them as the desired one. i.e. the UDF. |
| </li> |
| <li>If there is no expected data type but data type families are registered, try to coerce |
| operand to the family's default data type, i.e. the STRING family will have a VARCHAR type. |
| </li> |
| <li>If neither expected data type nor families are specified, try to find the tightest common |
| type of the node types, i.e. INTEGER and DOUBLE will return DOUBLE, the numeric precision |
| does not lose for this case.</li> |
| <li>If no tightest common type is found, try to find a wider type, i.e. STRING and INT |
| will return int, we allow some precision loss when widening DECIMAL to fractional, |
| or promote to STRING.</li> |
| </ul> |
| |
| <h3>Type Conversion Matrix</h3> |
| |
| <p>See <a href="https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing">CalciteImplicitCasts</a>.</div> |
| </div> |
| <!-- ======= 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 class="navBarCell1Rev">程序包</li> |
| <li>类</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/package-summary.html">上一个程序包</a></li> |
| <li><a href="../../../../../../org/apache/calcite/sql2rel/package-summary.html">下一个程序包</a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../index.html?org/apache/calcite/sql/validate/implicit/package-summary.html" target="_top">框架</a></li> |
| <li><a href="package-summary.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> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| <p class="legalCopy"><small>Copyright © 2012-2020 Apache Software Foundation. All Rights Reserved.</small></p> |
| </body> |
| </html> |