<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How do I create a hive table as select from a table from a different hive database in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-hive-table-as-select-from-a-table-from-a/m-p/644970#M192734</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am trying to create a table in a Hive database reading data from a different Hive database. If I do it with implicit sql, it works:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;OPTION SASTRACE=',,,ds' SASTRACELOC=SASLOG NOSTSUFFIX SQLIPONEATTEMPT SQL_IP_TRACE=(note, source) msglevel=i;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;proc sql;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;create table hvneglab.ci0101_tablaneglab_sas4 as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;select ci0101_numpersona &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;from hvnego.ci0101&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;where ci0101_nroperiod eq 2003&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;and meta_codienti = '2095';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;quit;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;OPTIONS SASTRACE=off;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I try to do it with Explicit SQL pass-through I am not able to make it work. This is the way I am doing it:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;proc sql;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;connect using HVNEGLAB as A;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;connect using HVNEGO as B;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;select * from connection to A(&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;create table ci0101_tablaneglab_sas3 as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;select * from connection to B( &lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;select ci0101_numpersona &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;from ci0101&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;where ci0101_nroperiod eq 2003&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;and meta_codienti = '2095'));&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;execute(disconnect from B) by A;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;disconnect from A;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first 2 lines need to remain as they are, since users are not allowed to create a connection to a database themselves. They can only do it by using one of the pre-assigned libraries they have available: hvneglab o hvnego&lt;/P&gt;&lt;P&gt;The error I get is:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2" color="#FF0000"&gt;ERROR: Prepare error: org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED: ParseException line &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#FF0000"&gt;1:65 cannot recognize input near 'connection' 'to' 'B' in from source&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#FF0000"&gt;SQL statement: create table ci0101_tablaneglab_sas3 as select * from connection to B( select ci0101_numpersona from ci0101 where &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#FF0000"&gt;ci0101_nroperiod eq 2003 and meta_codienti = '2095')&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone advise how to do it?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
    <pubDate>Mon, 04 May 2020 12:55:51 GMT</pubDate>
    <dc:creator>OGA</dc:creator>
    <dc:date>2020-05-04T12:55:51Z</dc:date>
    <item>
      <title>How do I create a hive table as select from a table from a different hive database</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-hive-table-as-select-from-a-table-from-a/m-p/644970#M192734</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am trying to create a table in a Hive database reading data from a different Hive database. If I do it with implicit sql, it works:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;OPTION SASTRACE=',,,ds' SASTRACELOC=SASLOG NOSTSUFFIX SQLIPONEATTEMPT SQL_IP_TRACE=(note, source) msglevel=i;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;proc sql;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;create table hvneglab.ci0101_tablaneglab_sas4 as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;select ci0101_numpersona &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;from hvnego.ci0101&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;where ci0101_nroperiod eq 2003&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;and meta_codienti = '2095';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;quit;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;OPTIONS SASTRACE=off;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I try to do it with Explicit SQL pass-through I am not able to make it work. This is the way I am doing it:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;proc sql;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;connect using HVNEGLAB as A;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;connect using HVNEGO as B;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;select * from connection to A(&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;create table ci0101_tablaneglab_sas3 as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;select * from connection to B( &lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;select ci0101_numpersona &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;from ci0101&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;where ci0101_nroperiod eq 2003&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;and meta_codienti = '2095'));&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;execute(disconnect from B) by A;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;disconnect from A;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first 2 lines need to remain as they are, since users are not allowed to create a connection to a database themselves. They can only do it by using one of the pre-assigned libraries they have available: hvneglab o hvnego&lt;/P&gt;&lt;P&gt;The error I get is:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2" color="#FF0000"&gt;ERROR: Prepare error: org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED: ParseException line &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#FF0000"&gt;1:65 cannot recognize input near 'connection' 'to' 'B' in from source&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#FF0000"&gt;SQL statement: create table ci0101_tablaneglab_sas3 as select * from connection to B( select ci0101_numpersona from ci0101 where &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#FF0000"&gt;ci0101_nroperiod eq 2003 and meta_codienti = '2095')&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone advise how to do it?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 12:55:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-hive-table-as-select-from-a-table-from-a/m-p/644970#M192734</guid>
      <dc:creator>OGA</dc:creator>
      <dc:date>2020-05-04T12:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a hive table as select from a table from a different hive database</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-hive-table-as-select-from-a-table-from-a/m-p/645115#M192782</link>
      <description>&lt;P&gt;Either you connect to A or to B.&lt;/P&gt;
&lt;P&gt;In the first piece of code, SAS reads the data from B and then writes it to A.&lt;/P&gt;
&lt;P&gt;In the second piece, SAS does nothing. The code in blue is run by Hadoop.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;proc sql;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;connect using HVNEGLAB as A;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;connect using HVNEGO as B;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;&lt;STRONG&gt;execute by A&lt;/STRONG&gt; (&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;create table ci0101_tablaneglab_sas3 as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;select * from connection to B(&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;select ci0101_numpersona&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;from ci0101&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;where ci0101_nroperiod eq 2003&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;&lt;FONT color="#0000FF"&gt;and meta_codienti = '2095')&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;execute(disconnect from B) by A;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;disconnect from A;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;SAS has no idea what the blue code means.&lt;/P&gt;
&lt;P&gt;And Hadoop has no idea what B is.&lt;/P&gt;
&lt;P&gt;The blue code is Hadoop code. You need a Hadoop reference there.&lt;/P&gt;
&lt;P&gt;Ask the Hadoop people. Maybe something like:&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;&lt;STRONG&gt;execute by A&lt;/STRONG&gt; (&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;create table ci0101_tablaneglab_sas3 as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;select &lt;/FONT&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt; ci0101_numpersona&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;from hvnego.ci0101&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;where ci0101_nroperiod eq 2003&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;&lt;FONT color="#0000FF"&gt;and meta_codienti = '2095'&lt;FONT color="#000000"&gt; );&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Note that since you have a create table in your Hadoop code, SAS retrieves no data.&lt;/P&gt;
&lt;P&gt;So you must use &lt;STRONG&gt;execute by&lt;/STRONG&gt;, not &lt;STRONG&gt;select from:&lt;/STRONG&gt;&amp;nbsp;You are not selecting anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 21:57:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-hive-table-as-select-from-a-table-from-a/m-p/645115#M192782</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-05-04T21:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a hive table as select from a table from a different hive database</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-hive-table-as-select-from-a-table-from-a/m-p/646182#M193261</link>
      <description>&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2020 12:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-hive-table-as-select-from-a-table-from-a/m-p/646182#M193261</guid>
      <dc:creator>OGA</dc:creator>
      <dc:date>2020-05-08T12:26:03Z</dc:date>
    </item>
  </channel>
</rss>

