<?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>question Re: select count(*)  command failing in Phoenix in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/select-count-command-failing-in-Phoenix/m-p/219899#M79475</link>
    <description>&lt;P&gt;yes that fixed the issue ..thanks a lot&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jun 2018 23:44:46 GMT</pubDate>
    <dc:creator>aliyesami</dc:creator>
    <dc:date>2018-06-11T23:44:46Z</dc:date>
    <item>
      <title>select count(*)  command failing in Phoenix</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/select-count-command-failing-in-Phoenix/m-p/219897#M79473</link>
      <description>&lt;P&gt;the 'select * from emp'  command works but if i execute the command 'select count(*) from emp' from a java api it fails. i am giving the code and the error below .&lt;/P&gt;&lt;P&gt;code &lt;/P&gt;&lt;PRE&gt;# cat  phoenixTest.java
import java.sql.*;
import java.util.*;
import org.apache.phoenix.jdbc.PhoenixDriver;
public class phoenixTest {
    public static void main(String args[]) throws Exception {
        Connection conn;
        Properties prop = new Properties();
        Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
        conn =  DriverManager.getConnection("jdbc:phoenix:hadoop1:2181:/hbase-unsecure");
        System.out.println("got connection");
        ResultSet rst = conn.createStatement().executeQuery("select count(*) from emp");
        while (rst.next()) {
            System.out.println(rst.getString(1) + " " + rst.getString(2));
        }
        conn.commit();
    }
}

&lt;/PRE&gt;&lt;P&gt;error &lt;/P&gt;&lt;PRE&gt;got connection
18/06/11 11:30:23 DEBUG jdbc.PhoenixStatement: Execute query: select count(*) from emp
18/06/11 11:30:23 DEBUG compile.FromCompiler: Re-resolved stale table EMP with seqNum 2 at timestamp 1522943831949 with 3 columns: [ID, 0 .FNAME, 0.LNAME]
18/06/11 11:30:23 DEBUG compile.FromCompiler: Re-resolved stale table LNAMEIDX with seqNum 0 at timestamp 1522943474697 with 2 columns: [ 0:LNAME, :ID]
18/06/11 11:30:23 DEBUG compile.FromCompiler: Re-resolved stale table EMP with seqNum 2 at timestamp 1522943831949 with 3 columns: [ID, 0 .FNAME, 0.LNAME]
18/06/11 11:30:23 DEBUG compile.FromCompiler: Re-resolved stale table LNAMEIDXCOVER with seqNum 0 at timestamp 1522943831949 with 3 colum ns: [0:LNAME, :ID, 0.0:FNAME]
18/06/11 11:30:23 DEBUG compile.FromCompiler: Re-resolved stale table EMP with seqNum 2 at timestamp 1522943831949 with 3 columns: [ID, 0 .FNAME, 0.LNAME]
18/06/11 11:30:23 DEBUG execute.BaseQueryPlan: Scan ready for iteration: {"loadColumnFamiliesOnDemand":null,"startRow":"","stopRow":"","b atch":-1,"cacheBlocks":true,"totalColumns":0,"maxResultSize":-1,"families":{},"caching":100,"maxVersions":1,"timeRange":[0,1528731024323] }
18/06/11 11:30:23 DEBUG ipc.AbstractRpcClient: Use SIMPLE authentication for service ClientService, sasl=false
18/06/11 11:30:23 DEBUG ipc.AbstractRpcClient: Connecting to hadoop4.tolls.dot.state.fl.us/10.100.44.18:16020
18/06/11 11:30:23 DEBUG execute.BaseQueryPlan: Iterator ready: UngroupedAggregatingResultIterator [hasRows=false, aggregators=org.apache. phoenix.expression.aggregator.ClientAggregators [1]:    0) COUNT(1)]
18/06/11 11:30:23 DEBUG jdbc.PhoenixStatement: Explain plan: CLIENT 1-CHUNK 0 ROWS 0 BYTES PARALLEL 1-WAY FULL SCAN OVER LNAMEIDX
    SERVER FILTER BY FIRST KEY ONLY
    SERVER AGGREGATE INTO SINGLE ROW
18/06/11 11:30:23 DEBUG iterate.BaseResultIterators: Getting iterators for ResultIterators [name=PARALLEL,id=57d408d6-987a-412f-8ace-2293 2851ed10,scans=[[{"loadColumnFamiliesOnDemand":null,"filter":"FirstKeyOnlyFilter","startRow":"","stopRow":"","batch":-1,"cacheBlocks":tru e,"totalColumns":1,"maxResultSize":-1,"families":{"0":["_0"]},"caching":100,"maxVersions":1,"timeRange":[0,1528731024323]}]]]
18/06/11 11:30:23 DEBUG iterate.ParallelIterators: Id: 57d408d6-987a-412f-8ace-22932851ed10, Time: 10ms, Scan: {"loadColumnFamiliesOnDema nd":null,"filter":"FirstKeyOnlyFilter","startRow":"","stopRow":"","batch":-1,"cacheBlocks":true,"totalColumns":1,"maxResultSize":2097152, "families":{"0":["_0"]},"caching":100,"maxVersions":1,"timeRange":[0,1528731024323]}
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
        at java.util.ArrayList.rangeCheck(ArrayList.java:653)
        at java.util.ArrayList.get(ArrayList.java:429)
        at java.util.Collections$UnmodifiableList.get(Collections.java:1309)
        at org.apache.phoenix.compile.RowProjector.getColumnProjector(RowProjector.java:167)
        at org.apache.phoenix.jdbc.PhoenixResultSet.getString(PhoenixResultSet.java:606)
        at phoenixTest.main(phoenixTest.java:14)
18/06/11 11:30:23 DEBUG util.ShutdownHookManager: ShutdownHookManger complete shutdown.
&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jun 2018 22:39:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/select-count-command-failing-in-Phoenix/m-p/219897#M79473</guid>
      <dc:creator>aliyesami</dc:creator>
      <dc:date>2018-06-11T22:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: select count(*)  command failing in Phoenix</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/select-count-command-failing-in-Phoenix/m-p/219898#M79474</link>
      <description>&lt;P&gt; &lt;A rel="user" href="https://community.cloudera.com/users/10115/sahmad43.html" nodeid="10115"&gt;@Sami Ahmad&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;When you run "select count(*) from emp" , the size of rst (ResultSet) will be only 1. So rst.getString(2) will give IndexOutOfBoundsException.&lt;/P&gt;&lt;P&gt;Remove rst.getString(2) when you run select count(*) from emp and it will work properly.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Please "Accept" the answer if this works for you.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;-Aditya&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 23:00:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/select-count-command-failing-in-Phoenix/m-p/219898#M79474</guid>
      <dc:creator>asirna</dc:creator>
      <dc:date>2018-06-11T23:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: select count(*)  command failing in Phoenix</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/select-count-command-failing-in-Phoenix/m-p/219899#M79475</link>
      <description>&lt;P&gt;yes that fixed the issue ..thanks a lot&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 23:44:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/select-count-command-failing-in-Phoenix/m-p/219899#M79475</guid>
      <dc:creator>aliyesami</dc:creator>
      <dc:date>2018-06-11T23:44:46Z</dc:date>
    </item>
  </channel>
</rss>

