# Apache phoenix source

**URL:** <https://community.dremio.com/t/apache-phoenix-source/572>\
**Category:** Uncategorized\
**Created:** [December 18, 2017, 11:32pm UTC](https://community.dremio.com/t/apache-phoenix-source/572 "2017-12-18T23:32:59Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pirion](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/pirion/32/324_2.png) [@Pirion](https://community.dremio.com/u/Pirion)\
**Post date:** [December 18, 2017, 11:32pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/1 "2017-12-18T23:32:59Z")

</div>

Have you plan to handle apache phoenix sources ?

---

<div class="post-metadata">

**Author:** ![kelly](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/kelly/32/11_2.png) [@kelly](https://community.dremio.com/u/kelly)\
**Post date:** [December 19, 2017, 6:54pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/2 "2017-12-19T18:54:59Z")

</div>

We do not currently have plans to handle Phoenix sources. Phoenix is oriented for OLTP-style queries. Our recommendation is to query HBase directly. Dremio can read from HBase and is optimized for scan-oriented, OLAP-style workloads.

We would love to hear more about your interest in querying Phoenix however. Perhaps there is something we have overlooked?

Kelly

---

<div class="post-metadata">

**Author:** ![Pirion](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/pirion/32/324_2.png) [@Pirion](https://community.dremio.com/u/Pirion)\
**Post date:** [December 19, 2017, 8:50pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/3 "2017-12-19T20:50:12Z")

</div>

I try to use hbase directly but, I have some problem to decode row\_key and timestamp value.

my datas are store in apache phoenix.  
For now all transformation are made with pig or phoenix.  
but end-user want to analyse row data en dremio seems to be perfect for that, If I success to read phoenix data from dremio.

---

<div class="post-metadata">

**Author:** ![kelly](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/kelly/32/11_2.png) [@kelly](https://community.dremio.com/u/kelly)\
**Post date:** [December 19, 2017, 9:03pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/4 "2017-12-19T21:03:45Z")

</div>

Did you see this tutorial? It might help you work through it: [https://www.dremio.com/tutorials/hbase-sql-dremio/](https://www.dremio.com/tutorials/hbase-sql-dremio/)

---

<div class="post-metadata">

**Author:** ![Pirion](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/pirion/32/324_2.png) [@Pirion](https://community.dremio.com/u/Pirion)\
**Post date:** [December 19, 2017, 11:18pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/5 "2017-12-19T23:18:37Z")

</div>

Yes of course,  
but timestamp of phoenix are encoded with 12 bytes.  
so I try CONVERT\_FROM with TIMESTAMP\_IMPALA,  
after I use BYTE\_SUBSTR to get 8 bytes timestamps and exclude nanosecond (0 in my case).  
but no result

in dremio : gAABYFHysiAAAAAA  
in phoenix: 2017-12-13 22:15:48.000  
long representation: 1513199748

---

<div class="post-metadata">

**Author:** ![Pirion](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/pirion/32/324_2.png) [@Pirion](https://community.dremio.com/u/Pirion)\
**Post date:** [December 20, 2017, 11:43am UTC](https://community.dremio.com/t/apache-phoenix-source/572/6 "2017-12-20T11:43:15Z")

</div>

I found a way to get my value but not in dremio

the binary representation of timestamp phoenix in binary is:  
10000000 00000000 00000001 01100000 01010001 11110010 10110010 00100000 00000000 00000000 00000000 00000000

I delete the last 4 bytes in order to exclude nano:  
10000000 00000000 00000001 01100000 01010001 11110010 10110010 00100000

if I change the first byte from 1 to 0 I have:  
00000000 00000000 00000001 01100000 01010001 11110010 10110010 00100000  
in decimal I have : 1513203348000  
which is the millisecond representation of my timestamp

there is away to replace the first bit in dremio ?

---

<div class="post-metadata">

**Author:** ![Pirion](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/pirion/32/324_2.png) [@Pirion](https://community.dremio.com/u/Pirion)\
**Post date:** [December 20, 2017, 6:32pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/7 "2017-12-20T18:32:41Z")

</div>

I found a way to decode phoenix timestamp in dremio:  
TO\_TIMESTAMP(cast( (CONVERT\_FROM(BYTE\_SUBSTR(\<TIMESTAMP COLUMN\>,1,8), ‘BIGINT\_BE’)+POW(2,63))/1000 as BIGINT) )

---

<div class="post-metadata">

**Author:** ![steven](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/steven/32/33_2.png) [@steven](https://community.dremio.com/u/steven)\
**Post date:** [December 20, 2017, 8:13pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/8 "2017-12-20T20:13:40Z")

</div>

I’m glad you found a solution, even though it’s not very pretty. I’ve opened an internal ticket to this and other Phoenix encodings to our supported encodings.

We also plan to release an SDK at some point, which would allow you to write a UDF to handle this case.

---

<div class="post-metadata">

**Author:** ![Pirion](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/pirion/32/324_2.png) [@Pirion](https://community.dremio.com/u/Pirion)\
**Post date:** [December 20, 2017, 8:39pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/9 "2017-12-20T20:39:38Z")

</div>

Great !!!  
i found a less ugly way:  
TO\_TIMESTAMP(cast( RSHIFT(LSHIFT(CONVERT\_FROM(BYTE\_SUBSTR(\<TIMESTAMP COLUMN\>,1,8), ‘BIGINT\_BE’),1),1)/1000 as BIGINT))

---

<div class="post-metadata">

**Author:** ![kelly](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/kelly/32/11_2.png) [@kelly](https://community.dremio.com/u/kelly)\
**Post date:** [December 20, 2017, 9:08pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/10 "2017-12-20T21:08:37Z")

</div>

I think you’ll find that if you build a data reflection on this source you’ll have much, much better performance.

Here’s a tutorial on that: [https://www.dremio.com/tutorials/getting-started-with-data-reflections/](https://www.dremio.com/tutorials/getting-started-with-data-reflections/)

---

<div class="post-metadata">

**Author:** ![Pirion](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/pirion/32/324_2.png) [@Pirion](https://community.dremio.com/u/Pirion)\
**Post date:** [December 20, 2017, 10:35pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/11 "2017-12-20T22:35:17Z")

</div>

I’m aware about data reflection thanks

---

<div class="post-metadata">

**Author:** ![Pirion](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/pirion/32/324_2.png) [@Pirion](https://community.dremio.com/u/Pirion)\
**Post date:** [December 21, 2017, 8:54pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/13 "2017-12-21T20:54:04Z")

</div>

for some table I have “SCHEMA\_CHANGE ERROR”.  
I think phoenix optimize the storage by not store some empty column.  
Do you have a solution for that ?

---

<div class="post-metadata">

**Author:** ![steven](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/steven/32/33_2.png) [@steven](https://community.dremio.com/u/steven)\
**Post date:** [December 21, 2017, 11:57pm UTC](https://community.dremio.com/t/apache-phoenix-source/572/14 "2017-12-21T23:57:20Z")

</div>

I would expect that this problem would go away after a few attempts, as we should be learning the new schema each time we encounter a new column. If the problem is not going away, that suggests something is not working right. Could you post the query profile for the query where this is occurring?

> [@How To Share A Query Profile](https://community.dremio.com/t/how-to-share-a-query-profile/148):
>
> Sometimes you may run into an issue and need to share your query profile with Dremio engineers or a sysadmin. This tutorial explains how to find your query profile and how to share it, whether you’re using the community or enterprise edition of Dremio: Comments or suggestions? Please post below. For a full list of our tutorials and other resources, please see: [https://www.dremio.com/resources/](https://www.dremio.com/resources/)

---

<div class="post-metadata">

**Author:** ![Pirion](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/pirion/32/324_2.png) [@Pirion](https://community.dremio.com/u/Pirion)\
**Post date:** [December 22, 2017, 8:38am UTC](https://community.dremio.com/t/apache-phoenix-source/572/15 "2017-12-22T08:38:13Z")

</div>

@steven, I have send you the query profil

---

<div class="post-metadata">

**Author:** ![Dominik](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/dominik/32/641_2.png) [@Dominik](https://community.dremio.com/u/Dominik)\
**Post date:** [May 30, 2018, 7:25am UTC](https://community.dremio.com/t/apache-phoenix-source/572/16 "2018-05-30T07:25:29Z")

</div>

I really think it would make a ton of sense if Dremio “understood” Phoenix tables. Doesn’t mean it should necessarily use the Phoenix JDBC driver, because that one is tuned towards OLTP, understand that.
