Files
doc-exports/docs/dli/sqlreference/dli_08_15048.html
Su, Xiaomeng be9eabe464 dli_sqlreference_20250305
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2025-03-25 09:06:21 +00:00

25 lines
4.3 KiB
HTML

<a name="dli_08_15048"></a><a name="dli_08_15048"></a>
<h1 class="topictitle1">Hive Dialect</h1>
<div id="body0000001712520806"><div class="section" id="dli_08_15048__section18937191211104"><h4 class="sectiontitle">Introduction</h4><p id="dli_08_15048__p86744015552">Starting from 1.11.0, Flink allows users to write SQL statements in Hive syntax when Hive dialect is used. By providing compatibility with Hive syntax, we aim to improve the interoperability with Hive and reduce the scenarios when users need to switch between Flink and Hive in order to execute different statements. For details, see <a href="https://nightlies.apache.org/flink/flink-docs-release-1.11/dev/table/hive/hive_dialect.html" target="_blank" rel="noopener noreferrer">Apache Flink Hive Dialect</a>.</p>
</div>
<div class="section" id="dli_08_15048__section1598811329411"><h4 class="sectiontitle">Function</h4><p id="dli_08_15048__p117928597387">Flink currently supports two SQL dialects: default and hive. You need to switch to Hive dialect before you can write in Hive syntax. The following describes how to set dialect with SQL Client.</p>
<p id="dli_08_15048__p13720115413597">Also notice that you can dynamically switch dialect for each statement you execute. There's no need to restart a session to use a different dialect.</p>
</div>
<div class="section" id="dli_08_15048__section892013201167"><h4 class="sectiontitle">Syntax</h4><p id="dli_08_15048__p65427471909">SQL dialect can be specified via the <strong id="dli_08_15048__b41061210153719">table.sql-dialect</strong> property.</p>
<div class="codecoloring" codetype="Sql" id="dli_08_15048__dli_08_0256_screen1461215294716"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">set</span><span class="w"> </span><span class="k">table</span><span class="p">.</span><span class="k">sql</span><span class="o">-</span><span class="n">dialect</span><span class="o">=</span><span class="n">hive</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="dli_08_15048__section154538489208"><h4 class="sectiontitle">Caveats</h4><ul id="dli_08_15048__ul1474942771016"><li id="dli_08_15048__li11749142761010">Hive dialect should only be used to process Hive meta objects, and requires the current catalog to be a <a href="https://nightlies.apache.org/flink/flink-docs-release-1.15/zh/docs/connectors/table/hive/hive_catalog/" target="_blank" rel="noopener noreferrer">HiveCatalog</a>.</li><li id="dli_08_15048__li12749122741018">Hive dialect only supports 2-part identifiers, so you can not specify catalog for an identifier. Refer to <a href="https://nightlies.apache.org/flink/flink-docs-release-1.15/docs/connectors/table/hive/hive_read_write/" target="_blank" rel="noopener noreferrer">Apache Flink Hive Read &amp; Write</a> for more details.<p id="dli_08_15048__p165772418583">While all Hive versions support the same syntax, whether a specific feature is available still depends on the <a href="https://nightlies.apache.org/flink/flink-docs-release-1.15/docs/connectors/table/hive/overview/#supported-hive-versions" target="_blank" rel="noopener noreferrer">Hive version</a> you use.</p>
<p id="dli_08_15048__p242835224414">For example, updating database location is only supported in Hive-2.4.0 or later.</p>
</li><li id="dli_08_15048__li8749142791019">Use <a href="https://nightlies.apache.org/flink/flink-docs-release-1.15/zh/docs/connectors/table/hive/hive_functions/#use-hive-built-in-functions-via-hivemodule" target="_blank" rel="noopener noreferrer">HiveModule</a> to run DML and DQL.</li><li id="dli_08_15048__li16749162711101">Since Flink 1.15 you need to swap flink-table-planner-loader located in <strong id="dli_08_15048__b174161437134117">/lib</strong> with <strong id="dli_08_15048__b17177104434112">flink-table-planner_2.12</strong> located in <strong id="dli_08_15048__b109841847144119">/opt</strong> to avoid the following exception. Please see <a href="https://issues.apache.org/jira/browse/FLINK-25128" target="_blank" rel="noopener noreferrer">FLINK-25128</a> for more details.</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_15046.html">Hive</a></div>
</div>
</div>