You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by Anchal Agrawal <an...@yahoo-inc.com> on 2015/07/22 02:43:35 UTC

Importing existing HBase table's rowkey

Hi,

I'm trying to map an existing HBase table to Phoenix. Can the existing HBase table's rowkey be imported as the rowkey of the Phoenix table? On this page (https://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table), there's an example:
CREATE VIEW t1 ( pk VARCHAR PRIMARY KEY, f1.val VARCHAR )
Here, is pk the HBase table's column that's being used as the primary key, or is it a Phoenix keyword/placeholder to refer to the HBase table's rowkey? My table's rowkey is made up of several fields that are not stored as columns in that table. If I could just import the rowkey into Phoenix, that'd be great.

Thank you!
Sincerely,Anchal

Re: Importing existing HBase table's rowkey

Posted by James Taylor <ja...@apache.org>.
Yes, UDFs are as of 4.4.0. I've corrected the JIRA.
Thanks,
James

On Wed, Jul 22, 2015 at 6:15 PM, Anchal Agrawal <an...@yahoo-inc.com>
wrote:

> Hi James,
>
> The long value isn't serialized that way. There's some internal
> serialization logic in the rowkey, so I'm writing a UDF to extract the long
> value. I looked at your tutorial
> <http://phoenix-hbase.blogspot.in/2013/04/how-to-add-your-own-built-in-function.html>
> for writing UDFs, and I'm also reading up various Phoenix functions here
> <https://github.com/apache/phoenix/tree/master/phoenix-core/src/main/java/org/apache/phoenix/expression/function>
> .
>
> Quick question - if I'm using v4.4.0, do I need to include the UDF in the
> Phoenix jar? JIRA [PHOENIX-538]
> <https://issues.apache.org/jira/browse/PHOENIX-538> says that the fix
> version is 5.0.0 but the Phoenix UDF page says that v4.4.0 supports UDFs
> with the CREATE FUNCTION query.
>
> Thank you,
> Anchal
>
>
>
>   On Wednesday, July 22, 2015 5:56 PM, James Taylor <
> jamestaylor@apache.org> wrote:
>
>
> If it leads with a long that was serialized using Bytes.toBytes(long),
> then you can map that to the UNSIGNED_LONG type in Phoenix. What's the rest
> of your row key look like?
>
> On Wed, Jul 22, 2015 at 5:54 PM, Anchal Agrawal <an...@yahoo-inc.com>
> wrote:
>
> Anil and Krishna,
>
> Thanks for your replies. My rowkey is made up of a LONG value with some
> other parameters added in. Krishna, that's what I was looking for! I've
> mapped the HBase table's rowkey to the Phoenix table, and I'm writing a UDF
> to extract fields from it.
>
> - Anchal
>
>
>
>   On Wednesday, July 22, 2015 4:04 PM, Krishna <re...@gmail.com>
> wrote:
>
>
> You can map HBase composite row key to Phoenix primary key only if
> serialization used for HBase matches with Phoenix. Ex: leading 1 byte for
> bucket, 0-byte char for separating columns, etc.
>
> If you used a different mechanism to serialize rowkey in HBase, you can
> still map it Phoenix table but declare PK as VARBINARY and see if you can
> create a UDF to separate columns.
>
> On Tuesday, July 21, 2015, Anchal Agrawal <an...@yahoo-inc.com> wrote:
>
> Hi,
>
> I'm trying to map an existing HBase table to Phoenix. Can the existing
> HBase table's rowkey be imported as the rowkey of the Phoenix table? On
> this page (
> https://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table),
> there's an example:
>
> CREATE VIEW t1 ( pk VARCHAR PRIMARY KEY, f1.val VARCHAR )
>
> Here, is pk the HBase table's column that's being used as the primary
> key, or is it a Phoenix keyword/placeholder to refer to the HBase table's
> rowkey? My table's rowkey is made up of several fields that are not stored
> as columns in that table. If I could just import the rowkey into Phoenix,
> that'd be great.
>
> Thank you!
>
> Sincerely,
> Anchal
>
>
>
>
>
>
>

Re: Importing existing HBase table's rowkey

Posted by Anchal Agrawal <an...@yahoo-inc.com>.
Hi James,
The long value isn't serialized that way. There's some internal serialization logic in the rowkey, so I'm writing a UDF to extract the long value. I looked at your tutorial for writing UDFs, and I'm also reading up various Phoenix functions here.
Quick question - if I'm using v4.4.0, do I need to include the UDF in the Phoenix jar? JIRA [PHOENIX-538] says that the fix version is 5.0.0 but the Phoenix UDF page says that v4.4.0 supports UDFs with the CREATE FUNCTION query.
Thank you,Anchal
 


     On Wednesday, July 22, 2015 5:56 PM, James Taylor <ja...@apache.org> wrote:
   

 If it leads with a long that was serialized using Bytes.toBytes(long), then you can map that to the UNSIGNED_LONG type in Phoenix. What's the rest of your row key look like?
On Wed, Jul 22, 2015 at 5:54 PM, Anchal Agrawal <an...@yahoo-inc.com> wrote:

Anil and Krishna,
Thanks for your replies. My rowkey is made up of a LONG value with some other parameters added in. Krishna, that's what I was looking for! I've mapped the HBase table's rowkey to the Phoenix table, and I'm writing a UDF to extract fields from it.
- Anchal 


     On Wednesday, July 22, 2015 4:04 PM, Krishna <re...@gmail.com> wrote:
   

 You can map HBase composite row key to Phoenix primary key only if serialization used for HBase matches with Phoenix. Ex: leading 1 byte for bucket, 0-byte char for separating columns, etc. 
If you used a different mechanism to serialize rowkey in HBase, you can still map it Phoenix table but declare PK as VARBINARY and see if you can create a UDF to separate columns. 

On Tuesday, July 21, 2015, Anchal Agrawal <an...@yahoo-inc.com> wrote:

Hi,

I'm trying to map an existing HBase table to Phoenix. Can the existing HBase table's rowkey be imported as the rowkey of the Phoenix table? On this page (https://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table), there's an example:
CREATE VIEW t1 ( pk VARCHAR PRIMARY KEY, f1.val VARCHAR )
Here, is pk the HBase table's column that's being used as the primary key, or is it a Phoenix keyword/placeholder to refer to the HBase table's rowkey? My table's rowkey is made up of several fields that are not stored as columns in that table. If I could just import the rowkey into Phoenix, that'd be great.

Thank you!
Sincerely,Anchal


   



  

Re: Importing existing HBase table's rowkey

Posted by James Taylor <ja...@apache.org>.
If it leads with a long that was serialized using Bytes.toBytes(long), then
you can map that to the UNSIGNED_LONG type in Phoenix. What's the rest of
your row key look like?

On Wed, Jul 22, 2015 at 5:54 PM, Anchal Agrawal <an...@yahoo-inc.com>
wrote:

> Anil and Krishna,
>
> Thanks for your replies. My rowkey is made up of a LONG value with some
> other parameters added in. Krishna, that's what I was looking for! I've
> mapped the HBase table's rowkey to the Phoenix table, and I'm writing a UDF
> to extract fields from it.
>
> - Anchal
>
>
>
>   On Wednesday, July 22, 2015 4:04 PM, Krishna <re...@gmail.com>
> wrote:
>
>
> You can map HBase composite row key to Phoenix primary key only if
> serialization used for HBase matches with Phoenix. Ex: leading 1 byte for
> bucket, 0-byte char for separating columns, etc.
>
> If you used a different mechanism to serialize rowkey in HBase, you can
> still map it Phoenix table but declare PK as VARBINARY and see if you can
> create a UDF to separate columns.
>
> On Tuesday, July 21, 2015, Anchal Agrawal <an...@yahoo-inc.com> wrote:
>
> Hi,
>
> I'm trying to map an existing HBase table to Phoenix. Can the existing
> HBase table's rowkey be imported as the rowkey of the Phoenix table? On
> this page (
> https://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table),
> there's an example:
>
> CREATE VIEW t1 ( pk VARCHAR PRIMARY KEY, f1.val VARCHAR )
>
> Here, is pk the HBase table's column that's being used as the primary
> key, or is it a Phoenix keyword/placeholder to refer to the HBase table's
> rowkey? My table's rowkey is made up of several fields that are not stored
> as columns in that table. If I could just import the rowkey into Phoenix,
> that'd be great.
>
> Thank you!
>
> Sincerely,
> Anchal
>
>
>
>

Re: Importing existing HBase table's rowkey

Posted by Anchal Agrawal <an...@yahoo-inc.com>.
Anil and Krishna,
Thanks for your replies. My rowkey is made up of a LONG value with some other parameters added in. Krishna, that's what I was looking for! I've mapped the HBase table's rowkey to the Phoenix table, and I'm writing a UDF to extract fields from it.
- Anchal 


     On Wednesday, July 22, 2015 4:04 PM, Krishna <re...@gmail.com> wrote:
   

 You can map HBase composite row key to Phoenix primary key only if serialization used for HBase matches with Phoenix. Ex: leading 1 byte for bucket, 0-byte char for separating columns, etc. 
If you used a different mechanism to serialize rowkey in HBase, you can still map it Phoenix table but declare PK as VARBINARY and see if you can create a UDF to separate columns. 

On Tuesday, July 21, 2015, Anchal Agrawal <an...@yahoo-inc.com> wrote:

Hi,

I'm trying to map an existing HBase table to Phoenix. Can the existing HBase table's rowkey be imported as the rowkey of the Phoenix table? On this page (https://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table), there's an example:
CREATE VIEW t1 ( pk VARCHAR PRIMARY KEY, f1.val VARCHAR )
Here, is pk the HBase table's column that's being used as the primary key, or is it a Phoenix keyword/placeholder to refer to the HBase table's rowkey? My table's rowkey is made up of several fields that are not stored as columns in that table. If I could just import the rowkey into Phoenix, that'd be great.

Thank you!
Sincerely,Anchal


  

Re: Importing existing HBase table's rowkey

Posted by Krishna <re...@gmail.com>.
You can map HBase composite row key to Phoenix primary key only if
serialization used for HBase matches with Phoenix. Ex: leading 1 byte for
bucket, 0-byte char for separating columns, etc.

If you used a different mechanism to serialize rowkey in HBase, you can
still map it Phoenix table but declare PK as VARBINARY and see if you can
create a UDF to separate columns.

On Tuesday, July 21, 2015, Anchal Agrawal <an...@yahoo-inc.com> wrote:

> Hi,
>
> I'm trying to map an existing HBase table to Phoenix. Can the existing
> HBase table's rowkey be imported as the rowkey of the Phoenix table? On
> this page (
> https://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table),
> there's an example:
>
> CREATE VIEW t1 ( pk VARCHAR PRIMARY KEY, f1.val VARCHAR )
>
> Here, is pk the HBase table's column that's being used as the primary
> key, or is it a Phoenix keyword/placeholder to refer to the HBase table's
> rowkey? My table's rowkey is made up of several fields that are not stored
> as columns in that table. If I could just import the rowkey into Phoenix,
> that'd be great.
>
> Thank you!
>
> Sincerely,
> Anchal
>

Re: Importing existing HBase table's rowkey

Posted by anil gupta <an...@gmail.com>.
Can you share your composite rowkey? Do you have strings in your rowkey?
Phoenix has a particular format for composite Rowkey with String.

On Tue, Jul 21, 2015 at 5:43 PM, Anchal Agrawal <an...@yahoo-inc.com>
wrote:

> Hi,
>
> I'm trying to map an existing HBase table to Phoenix. Can the existing
> HBase table's rowkey be imported as the rowkey of the Phoenix table? On
> this page (
> https://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table),
> there's an example:
>
> CREATE VIEW t1 ( pk VARCHAR PRIMARY KEY, f1.val VARCHAR )
>
> Here, is pk the HBase table's column that's being used as the primary
> key, or is it a Phoenix keyword/placeholder to refer to the HBase table's
> rowkey? My table's rowkey is made up of several fields that are not stored
> as columns in that table. If I could just import the rowkey into Phoenix,
> that'd be great.
>
> Thank you!
>
> Sincerely,
> Anchal
>



-- 
Thanks & Regards,
Anil Gupta