doc-exports/docs/dws/dev/dws_04_0214.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

268 lines
53 KiB
HTML

<a name="EN-US_TOPIC_0000001233563249"></a><a name="EN-US_TOPIC_0000001233563249"></a>
<h1 class="topictitle1">Creating a Foreign Table</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p12167448953">This section describes how to create a Hadoop foreign table in the <span id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_ph1692512422530">GaussDB(DWS)</span> database to access the Hadoop structured data stored on MRS HDFS. A Hadoop foreign table is read-only. It can only be queried using <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0058966095_b84235270616358">SELECT</strong>.</p>
<div class="section" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section1781317284522"><h4 class="sectiontitle">Prerequisites</h4><ul id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ul14134183317521"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li16135183315529">You have created an MRS cluster and imported data to the ORC table in the Hive/Spark database.<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p201202236143"><a name="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li16135183315529"></a><a name="en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li16135183315529"></a>For details, see <a href="dws_04_0212.html">Preparing Data in an MRS Cluster</a>.</p>
</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li413773395211">You have created an MRS data source connection for the <span id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_ph1231065219554">GaussDB(DWS)</span> cluster.<p id="EN-US_TOPIC_0000001233563249__p157501812276"><span id="EN-US_TOPIC_0000001233563249__ph1242365913277">For details, see section "MRS Data Sources &gt; Creating an MRS Data Source Connection" in the <em id="EN-US_TOPIC_0000001233563249__i4422105972712">Data Warehouse Service User Guide</em>.</span></p>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section129581728111417"><a name="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section129581728111417"></a><a name="en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section129581728111417"></a><h4 class="sectiontitle">Obtaining the HDFS Path of the MRS Data Source</h4><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p17188143052113">There are two methods for you to obtain the HDFS path.</p>
<ul id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ul136721313192218"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li1967241362218"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b1916355181810">Method 1</strong><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1146913578211">For Hive data, log in to the Hive client of MRS (see <a href="dws_04_0212.html#EN-US_TOPIC_0000001188642198__en-us_topic_0000001082830951_en-us_topic_0109259515_en-us_topic_0101477888_li14725131112614">2</a>), run the following command to view the detailed information about the table, and record the data storage path in the <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b1946122319525">location</strong> parameter:</p>
<pre class="screen" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_screen0471185712219">use <em id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_i1649208145">&lt;database_name&gt;</em>;
desc formatted <em id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_i1947595719217">&lt;</em><em id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_i54751575215">table_name&gt;</em>;</pre>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p447735792116">For example, if the value of the <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b1334107771145413">location</strong> parameter in the returned result is <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b842352706145431">hdfs://hacluster/user/hive/warehouse/demo.db/product_info_orc/</strong>, the HDFS path is <span class="filepath" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_filepath1907981943145454"><b>/user/hive/warehouse/demo.db/product_info_orc/</b></span>.</p>
</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li1734942419246"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b1891131519203">Method 2</strong><div class="p" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p12857598199">Perform the following steps to obtain the HDFS path:<ol id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ol133446512517"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li3342652252">Log in to the MRS management console.</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li113444515257">Choose <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b16983835112010">Cluster</strong> &gt; <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b2098314351209">Active Cluster</strong> and click the name of the cluster to be queried to enter the page displaying the cluster's basic information.</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li183449512519">Click <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b842352706145831">File Management</strong> and select <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b842352706145836">HDFS File List</strong>.</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li334495162512">Go to the storage directory of the data to be imported to the <span id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_ph1271435905518">GaussDB(DWS)</span> cluster and record the path.<div class="fignone" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_fig2034415511255"><span class="figcap"><b>Figure 1 </b>Checking the data storage path on MRS</span><br><span><img id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_image78001435185912" src="figure/en-us_image_0000001188323786.png"></span></div>
</li></ol>
</div>
</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section1760214326239"><a name="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section1760214326239"></a><a name="en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section1760214326239"></a><h4 class="sectiontitle">Obtaining Information About the Foreign Server Connected to the MRS Data Source</h4><ol id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ol12476147152417"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li13611353115919"><span>Use the user who creates the foreign server to connect to the corresponding database.</span><p><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1142911556417">Determine whether to use a common user to create a foreign table in the customized database based on requirements.</p>
<ul id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ul13937828193619"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li6936228103619"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b172811246122311">Yes</strong><ol type="a" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ol19707185114362"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li17131512367">Ensure that you have created the common user <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b84235270615437">dbuser</strong> and its database <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b84235270615453">mydatabase</strong>, and manually created a foreign server in <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b35320274015532">mydatabase</strong> by following steps in <a href="dws_04_0213.html">Manually Creating a Foreign Server</a>.</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_li82301159133818">Connect to the database <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b1669582716232">mydatabase</strong> as user <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b20709104620236">dbuser</strong> through the database client tool provided by <span id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_ph5753153755611">GaussDB(DWS)</span>.<div class="p" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_p20172546401">If you have connected to the database using the gsql client, run the following command to switch the user and database:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_screen1675425183610"><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="err">\</span><span class="k">c</span><span class="w"> </span><span class="n">mydatabase</span><span class="w"> </span><span class="n">dbuser</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p548195616400">Enter your password as prompted.</p>
</li></ol>
</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li1993716286361"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b2097615522510">No</strong><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p355519151375">When you create an MRS data source connection on the <span id="EN-US_TOPIC_0000001233563249__ph36809169357">GaussDB(DWS)</span> management console, the database administrator <strong id="EN-US_TOPIC_0000001233563249__b6687121663510">dbadmin</strong> automatically creates a foreign server in the default database <strong id="EN-US_TOPIC_0000001233563249__b1668713168359">postgres</strong>. If you create a foreign table in the default database <strong id="EN-US_TOPIC_0000001233563249__b26871016113513">postgres</strong> as the database administrator <strong id="EN-US_TOPIC_0000001233563249__b868781614355">dbadmin</strong>, you need to connect to the database using the database client tool provided by <span id="EN-US_TOPIC_0000001233563249__ph15688131614359">GaussDB(DWS)</span>. For example, use the <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b1347119494222">gsql</strong> client to connect to the database by running the following command:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_screen13743164063710"><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="n">gsql</span><span class="w"> </span><span class="o">-</span><span class="n">d</span><span class="w"> </span><span class="n">postgres</span><span class="w"> </span><span class="o">-</span><span class="n">h</span><span class="w"> </span><span class="mi">192</span><span class="p">.</span><span class="mi">168</span><span class="p">.</span><span class="mi">2</span><span class="p">.</span><span class="mi">30</span><span class="w"> </span><span class="o">-</span><span class="n">U</span><span class="w"> </span><span class="n">dbadmin</span><span class="w"> </span><span class="o">-</span><span class="n">p</span><span class="w"> </span><span class="mi">8000</span><span class="w"> </span><span class="o">-</span><span class="n">W</span><span class="w"> </span><span class="n">password</span><span class="w"> </span><span class="o">-</span><span class="n">r</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</p></li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li18478174710244"><span>Run the following command to view the information about the created foreign server connected to the MRS data source:</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_screen118215315457"><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">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_foreign_server</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<div class="note" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_note101897431935"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p333312266017">You can also run the <b><span class="cmdname" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_cmdname22281521312">\desc+</span></b> command to view the information about the foreign server.</p>
</div></div>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p15187133154510">The returned result is as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_screen41891314454"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span></pre></div></td><td class="code"><div><pre><span></span><span class="w"> </span><span class="n">srvname</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">srvowner</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">srvfdw</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">srvtype</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">srvversion</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">srvacl</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">srvoptions</span>
<span class="c1">--------------------------------------------------+----------+--------+---------+------------+--------+---------------------------------------------------------------------------------------------------------------------</span>
<span class="w"> </span><span class="n">gsmpp_server</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="mi">10</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="mi">13673</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="n">gsmpp_errorinfo_server</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="mi">10</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="mi">13678</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">|</span>
<span class="w"> </span><span class="n">hdfs_server_8f79ada0_d998_4026_9020_80d6de2692ca</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="mi">16476</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="mi">13685</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="err">{</span><span class="ss">&quot;address=192.168.1.245:25000,192.168.1.218:25000&quot;</span><span class="p">,</span><span class="n">hdfscfgpath</span><span class="o">=/</span><span class="n">MRS</span><span class="o">/</span><span class="mi">8</span><span class="n">f79ada0</span><span class="o">-</span><span class="n">d998</span><span class="o">-</span><span class="mi">4026</span><span class="o">-</span><span class="mi">9020</span><span class="o">-</span><span class="mi">80</span><span class="n">d6de2692ca</span><span class="p">,</span><span class="k">type</span><span class="o">=</span><span class="n">hdfs</span><span class="err">}</span>
<span class="p">(</span><span class="mi">3</span><span class="w"> </span><span class="k">rows</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p531413583431">In the query result, each row contains the information about a foreign server. The foreign server associated with the MRS data source connection contains the following information:</p>
<ul id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ul9646826184420"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li19646202694414">The value of <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b842352706114911">srvname</strong> contains <span class="parmvalue" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_parmvalue440033319114926"><b>hdfs_server</b></span> and the ID of the MRS cluster, which is the same as the MRS ID in the cluster list on the MRS management console.</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li10646626134415">The <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b84235270611527">address</strong> parameter in the <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b842352706115211">srvoptions</strong> field contains the IP addresses and ports of the active and standby nodes in the MRS cluster.</li></ul>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1279539193313">You can find the foreign server you want based on the above information and record the values of its <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b48351024162815">srvname</strong> and <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b4835162462810">srvoptions</strong>.</p>
</p></li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section1736065499"><h4 class="sectiontitle">Creating a Foreign Table</h4><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1705153311264">After <a href="#EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section1760214326239">Obtaining Information About the Foreign Server Connected to the MRS Data Source</a> and <a href="#EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section129581728111417">Obtaining the HDFS Path of the MRS Data Source</a> are completed, you can create a foreign table to read data from the MRS data source.</p>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p33659853185314">The syntax for creating a foreign table is as follows. For details, see the syntax <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b589124105111">CREATE FOREIGN TABLE (SQL on Hadoop or OBS)</strong>.</p>
<pre class="screen" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_screen34509377483">CREATE FOREIGN TABLE [ IF NOT EXISTS ] table_name
( [ { column_name type_name
[ { [CONSTRAINT constraint_name] NULL |
[CONSTRAINT constraint_name] NOT NULL |
column_constraint [...]} ] |
table_constraint [, ...]} [, ...] ] )
SERVER dfs_server
OPTIONS ( { option_name ' value ' } [, ...] )
DISTRIBUTE BY {ROUNDROBIN | REPLICATION}
[ PARTITION BY ( column_name ) [ AUTOMAPPED ] ] ;</pre>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p174842037174819">For example, when creating a foreign table named <em id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_i1783340117151611">foreign_</em><em id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_i132393128151611">product_info</em>, set parameters in the syntax as follows:</p>
<ul id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ul645584873919"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li0456164816391"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_b19458104873912">table_name</strong><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p14459164811399">Mandatory. This parameter specifies the name of the foreign table to be created.</p>
</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li25911413571">Table column definitions<ul id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ul496273711582"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li1446294810396"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_b846619483394">column_name</strong>: specifies the name of a column in the foreign table.</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li2471194833916"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_b447510488398">type_name</strong>: specifies the data type of the column.</li></ul>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p64441413214">Multiple columns are separate by commas (,).</p>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p54787484399">The number of columns and column types in the foreign table must be the same as those in the data stored on MRS. Learn <a href="#EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section185347544812">Data Type Conversion</a> before defining column data types.</p>
</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li4488164811399"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_b1449034813915">SERVER dfs_server</strong><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p114921548203913">This parameter specifies the foreign server name of the foreign table. This server must exist. The foreign table can read data from an MRS cluster by configuring the foreign server and connecting to the MRS data source.</p>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1192123102315">Enter the value of the <span class="parmname" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_parmname1909730423152523"><b>srvname</b></span> field queried in <a href="#EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section1760214326239">Obtaining Information About the Foreign Server Connected to the MRS Data Source</a>.</p>
</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li184991948153914"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b99731635153419">OPTIONS</strong> parameters<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p05031548113911">These are parameters associated with the foreign table. The key parameters are as follows:</p>
<ul id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ul16505124883912"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li13507154883911"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b842352706152618">format</strong>: This parameter is mandatory. The value can only be <span class="parmvalue" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_parmvalue143214336100"><b>orc</b></span>. It specifies the format of the source data file. Only Hive ORC files are supported.</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li1551404817391"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_b13517448173913">foldername</strong>: This parameter is mandatory. It specifies the HDFS directory for storing data or data file path.<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p195201748163913">If the MRS analysis cluster has enabled Kerberos authentication, ensure that the MRS user having the MRS data source connection has the read and write permissions for the directory.</p>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p721951062217">Follow the steps in <a href="#EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section129581728111417">Obtaining the HDFS Path of the MRS Data Source</a> to obtain the HDFS path, which is the value of parameter <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b121920811315291">foldername</strong>.</p>
</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li55231748173915"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b2066428218152911">encoding</strong>: This parameter is optional. It specifies the encoding format of a source data file in the foreign table. Its default value is <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b84235270620728">utf8</strong>.</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li5535248103910"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_b11561548103912">DISTRIBUTE BY</strong><div class="p" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p13101419191414">This parameter specifies the data read mode for the foreign table. There are two read modes supported. In this example, <strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_b842352706153029">ROUNDROBIN</strong> is selected.<ul id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_ul956334843917"><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li356519482392"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_b4831143565920">ROUNDROBIN</strong>: When a foreign table reads data from the data source, each node in a <span id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_ph1313912715572">GaussDB(DWS)</span> cluster randomly reads some data and integrates the random data to a complete data set.</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li11569144812393"><strong id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_b118311435195911">REPLICATION</strong>: When a foreign table reads data from the data source, each node in the <span id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_ph92397018572">GaussDB(DWS)</span> cluster reads a complete data set.</li></ul>
</div>
</li><li id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li17581162214187">Other parameters in the syntax<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p7632123791816"><a name="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li17581162214187"></a><a name="en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_li17581162214187"></a>Other parameters are optional and can be configured as required. In this example, they do not need to be configured.</p>
</li></ul>
</li></ul>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p5898193171031">Based on the above settings, the foreign table is created using the following statements:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_screen17865118123918"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span>
<span class="normal">18</span>
<span class="normal">19</span>
<span class="normal">20</span>
<span class="normal">21</span>
<span class="normal">22</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">DROP</span><span class="w"> </span><span class="k">FOREIGN</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="k">IF</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="n">foreign_product_info</span><span class="p">;</span>
<span class="k">CREATE</span><span class="w"> </span><span class="k">FOREIGN</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="n">foreign_product_info</span>
<span class="p">(</span>
<span class="w"> </span><span class="n">product_price</span><span class="w"> </span><span class="nb">integer</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_id</span><span class="w"> </span><span class="nb">char</span><span class="p">(</span><span class="mi">30</span><span class="p">)</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_time</span><span class="w"> </span><span class="nb">date</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_level</span><span class="w"> </span><span class="nb">char</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_name</span><span class="w"> </span><span class="nb">varchar</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_type1</span><span class="w"> </span><span class="nb">varchar</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_type2</span><span class="w"> </span><span class="nb">char</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_monthly_sales_cnt</span><span class="w"> </span><span class="nb">integer</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_comment_time</span><span class="w"> </span><span class="nb">date</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_comment_num</span><span class="w"> </span><span class="nb">integer</span><span class="w"> </span><span class="p">,</span>
<span class="w"> </span><span class="n">product_comment_content</span><span class="w"> </span><span class="nb">varchar</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span><span class="w"> </span>
<span class="p">)</span><span class="w"> </span><span class="n">SERVER</span><span class="w"> </span><span class="n">hdfs_server_8f79ada0_d998_4026_9020_80d6de2692ca</span><span class="w"> </span>
<span class="k">OPTIONS</span><span class="w"> </span><span class="p">(</span>
<span class="n">format</span><span class="w"> </span><span class="s1">'orc'</span><span class="p">,</span><span class="w"> </span>
<span class="k">encoding</span><span class="w"> </span><span class="s1">'utf8'</span><span class="p">,</span>
<span class="n">foldername</span><span class="w"> </span><span class="s1">'/user/hive/warehouse/demo.db/product_info_orc/'</span>
<span class="p">)</span><span class="w"> </span>
<span class="n">DISTRIBUTE</span><span class="w"> </span><span class="k">BY</span><span class="w"> </span><span class="n">ROUNDROBIN</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section185347544812"><a name="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section185347544812"></a><a name="en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_section185347544812"></a><h4 class="sectiontitle">Data Type Conversion</h4><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p795196194819">Data is imported to Hive/Spark and then stored on HDFS in ORC format. Actually, <span id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_ph3743191717574">GaussDB(DWS)</span> reads ORC files on HDFS, and queries and analyzes data in these files.</p>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p695126194811">Data types supported by Hive/Spark are different from those supported by <span id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_ph7194723125711">GaussDB(DWS)</span>. Therefore, you need to learn the mapping between them. <a href="#EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_table1410311611489">Table 1</a> describes the mapping in detail.</p>
<div class="tablenoborder"><a name="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_table1410311611489"></a><a name="en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_table1410311611489"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_table1410311611489" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Data type mapping</caption><thead align="left"><tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row2962615488"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.6.4.2.5.1.1"><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p15951865480">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="26%" id="mcps1.3.6.4.2.5.1.2"><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p2952674817">Column Type Supported by an HDFS/OBS Foreign Table of <span id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_ph064016105914">GaussDB(DWS)</span></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="28.000000000000004%" id="mcps1.3.6.4.2.5.1.3"><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p18961268488">Column Type Supported by a Hive Table</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="26%" id="mcps1.3.6.4.2.5.1.4"><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p3961664486">Column Type Supported by a Spark Table</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row129676144819"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p9961769489">Integer in two bytes</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p199611624811">SMALLINT</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p09612644811">SMALLINT</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1596186154810">SMALLINT</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row3978674818"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p59717644819">Integer in four bytes</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p09710664817">INTEGER</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1597176154812">INT</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p197116134813">INT</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row99816624811"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p8971861486">Integer in eight bytes</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1897966486">BIGINT</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p29713614817">BIGINT</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p159796204813">BIGINT</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row1198865484"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p10983610485">Single-precision floating point number</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p398146164813">FLOAT4 (REAL)</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p798186144816">FLOAT</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p179810614482">FLOAT</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row15992694815"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1798164485">Double-precision floating point number</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1998066487">FLOAT8(DOUBLE PRECISION)</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1698366482">DOUBLE</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p99919617484">FLOAT</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row13996694815"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p7991167481">Scientific data type</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1099146134816">DECIMAL[p (,s)]</p>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1899156134811">The maximum precision can reach up to 38.</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p19991568486">DECIMAL</p>
<p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p139986194810">The maximum precision can reach up to 38 (Hive 0.11).</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p16997619486">DECIMAL</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row4100196164812"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p13996644815">Date type</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p61001061484">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p141001068486">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1510013612483">DATE</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row111005654816"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p71006612488">Time type</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p610011654812">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p710010604818">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p191007614812">TIMESTAMP</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row17101165485"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1610117615487">BOOLEAN type</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p810146124812">BOOLEAN</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p6101762482">BOOLEAN</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p410115664812">BOOLEAN</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row171021614482"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p11016614483">CHAR type</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1910115619489">CHAR(n)</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p810117612489">CHAR (n)</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p91010644820">STRING</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row1102463483"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p16102176144811">VARCHAR type</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p310216184815">VARCHAR(n)</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p110212664818">VARCHAR (n)</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1310216644811">VARCHAR (n)</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_row111031962486"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.6.4.2.5.1.1 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1110210694811">String</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.2 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p210210612485">TEXT(CLOB)</p>
</td>
<td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.3.6.4.2.5.1.3 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1710217684816">STRING</p>
</td>
<td class="cellrowborder" valign="top" width="26%" headers="mcps1.3.6.4.2.5.1.4 "><p id="EN-US_TOPIC_0000001233563249__en-us_topic_0000001082927067_en-us_topic_0109259517_en-us_topic_0101477886_p1810312614812">STRING</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0210.html">Importing Data from MRS to a Cluster</a></div>
</div>
</div>