You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by Yiannis Gkoufas <jo...@gmail.com> on 2015/07/06 18:06:53 UTC

Perform Scan-like range query on VARBINARY key column

Hi all,

I have created a table in that way:

CREATE TABLE TWEETS (my_key VARBINARY, text varchar, tweetid varchar, user
varchar, date varchar, CONSTRAINT my_pk PRIMARY
KEY(my_key)) SALT_BUCKETS=120

my_key is a custom byte array key I have constructed

What I want to do is to actually perform a Scan on the key, but I cannot
use the Hbase Core API because of the Salting applied.

Any idea on how I can perform a range query on the key column?

Thanks a lot!

Re: Perform Scan-like range query on VARBINARY key column

Posted by Yiannis Gkoufas <jo...@gmail.com>.
Hi James,

the queries seem to work, but I am not getting the same results with a scan
in an unsalted hbase table (not phoenix) with the same data loaded, so
probably I am doing something wrong.
How can I debug the scans issued to hbase to validate that everything is
correct with my query?

Thanks a lot!

On 6 July 2015 at 23:55, Yiannis Gkoufas <jo...@gmail.com> wrote:

> Thanks James for your reply!
> I will give it a shot!
>
>
> On 6 July 2015 at 19:04, James Taylor <ja...@apache.org> wrote:
>
>> You can use a regular SQL query with comparison operators (=, <, <=, >,
>> >=, !=) against constants with your keys. Any type will be autocast to
>> VARBINARY and you can use PrepareStatement.setBytes(<colIndexOrString) for
>> bind variables that are arbitrary bytes for your key. The salting will
>> happen transparently, so  you don't have to do anything special.
>>
>> Thanks,
>> James
>>
>> On Mon, Jul 6, 2015 at 9:06 AM, Yiannis Gkoufas <jo...@gmail.com>
>> wrote:
>>
>>> Hi all,
>>>
>>> I have created a table in that way:
>>>
>>> CREATE TABLE TWEETS (my_key VARBINARY, text varchar, tweetid varchar,
>>> user varchar, date varchar, CONSTRAINT my_pk PRIMARY
>>> KEY(my_key)) SALT_BUCKETS=120
>>>
>>> my_key is a custom byte array key I have constructed
>>>
>>> What I want to do is to actually perform a Scan on the key, but I cannot
>>> use the Hbase Core API because of the Salting applied.
>>>
>>> Any idea on how I can perform a range query on the key column?
>>>
>>> Thanks a lot!
>>>
>>
>>
>

Re: Perform Scan-like range query on VARBINARY key column

Posted by Yiannis Gkoufas <jo...@gmail.com>.
Thanks James for your reply!
I will give it a shot!


On 6 July 2015 at 19:04, James Taylor <ja...@apache.org> wrote:

> You can use a regular SQL query with comparison operators (=, <, <=, >,
> >=, !=) against constants with your keys. Any type will be autocast to
> VARBINARY and you can use PrepareStatement.setBytes(<colIndexOrString) for
> bind variables that are arbitrary bytes for your key. The salting will
> happen transparently, so  you don't have to do anything special.
>
> Thanks,
> James
>
> On Mon, Jul 6, 2015 at 9:06 AM, Yiannis Gkoufas <jo...@gmail.com>
> wrote:
>
>> Hi all,
>>
>> I have created a table in that way:
>>
>> CREATE TABLE TWEETS (my_key VARBINARY, text varchar, tweetid varchar,
>> user varchar, date varchar, CONSTRAINT my_pk PRIMARY
>> KEY(my_key)) SALT_BUCKETS=120
>>
>> my_key is a custom byte array key I have constructed
>>
>> What I want to do is to actually perform a Scan on the key, but I cannot
>> use the Hbase Core API because of the Salting applied.
>>
>> Any idea on how I can perform a range query on the key column?
>>
>> Thanks a lot!
>>
>
>

Re: Perform Scan-like range query on VARBINARY key column

Posted by James Taylor <ja...@apache.org>.
You can use a regular SQL query with comparison operators (=, <, <=, >, >=,
!=) against constants with your keys. Any type will be autocast to
VARBINARY and you can use PrepareStatement.setBytes(<colIndexOrString) for
bind variables that are arbitrary bytes for your key. The salting will
happen transparently, so  you don't have to do anything special.

Thanks,
James

On Mon, Jul 6, 2015 at 9:06 AM, Yiannis Gkoufas <jo...@gmail.com>
wrote:

> Hi all,
>
> I have created a table in that way:
>
> CREATE TABLE TWEETS (my_key VARBINARY, text varchar, tweetid varchar, user
> varchar, date varchar, CONSTRAINT my_pk PRIMARY
> KEY(my_key)) SALT_BUCKETS=120
>
> my_key is a custom byte array key I have constructed
>
> What I want to do is to actually perform a Scan on the key, but I cannot
> use the Hbase Core API because of the Salting applied.
>
> Any idea on how I can perform a range query on the key column?
>
> Thanks a lot!
>