Sorry, no worky.

I have a table named TMP_SNACKS.  TMP_SNACKS has a few static fields and
many dynamic fields.  Usually there are only a few dynamic columns (5 or
less) that I am interested in.

One of the dynamic fields in TMP_SNACKS is "page_title".  I tried this:

create view MY_VIEW("page_title" varchar) as select * from TMP_SNACKS

Then I tried a select:
select "page_title" from MY_VIEW limit 1;
The result was
java.lang.RuntimeException:
org.apache.phoenix.exception.PhoenixIOException:
org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException: Column
family 0 does not exist in region
TMP_SNACKS,,1455911043400.8665a1ac6da8ffe95454a5299a8e55f3. ...

I may not have described my problem very well, but I have already played
around with the syntax a lot and am pretty sure there is no current
solution.  But I would love to be wrong.  :)

Thanks,
    Steve

On Thu, Feb 25, 2016 at 12:45 PM, James Taylor <jamestay...@apache.org>
wrote:

> Hi Steve,
>
> You can do what you want with a view today, but the syntax is just a bit
> different than what you tried. You declare your dynamic columns after the
> view name, like this:
>
>     create MY_VIEW("dynamic_field" varchar) as select * from MY_TABLE
>
> You can also alter a view and dynamically add/remove columns on-the-fly.
>
>     alter view MY_VIEW add "dynamic_field2" varchar;
>     alter view MY_VIEW drop column "dynamic_field1";
>
> You can even conditionally add a column only if it's not already there:
>
>     alter view MY_VIEW add if not exists "dynamic_field2" varchar;
>
> See full syntax here[1].
>
> It's a cheap operation, as the only thing that's happening behind the
> scenes is the update of the metadata. The advantage (as you've seen) is
> that Phoenix is tracking all your dynamic columns.
>
> Thanks,
> James
>
> [1] https://phoenix.apache.org/language/index.html#alter
>
> On Thu, Feb 25, 2016 at 3:31 AM, anil gupta <anilgupt...@gmail.com> wrote:
>
>> +1 for a view that has dynamic columns. This would make life easier with
>> dynamic columns.
>>
>> On Tue, Feb 23, 2016 at 4:00 PM, Steve Terrell <sterr...@oculus360.us>
>> wrote:
>>
>>> I have a table with many dynamic fields.  Works great.  However, it's a
>>> bit of a nuisance to have to supply each dynamic field's type in every
>>> query.
>>>
>>> Example:
>>> select "dynamic_field" from MY_TABLE("dynamic_field" varchar)
>>>
>>> This example is not too bad, but image it with 5+ dynamic fields being
>>> used.  The select statement becomes very verbose.
>>>
>>> I understand the reason behind requiring the field type of each dynamic
>>> field.  But I was wondering if there is a way to define a view that manages
>>> the dynamic field types so that I could do something like this:
>>>
>>> create MY_VIEW as select * from MY_TABLE("dynamic_field" varchar)
>>> -- invalid syntax; pseudo code of what I wish I could do.
>>>
>>> select "dynamic_field" from MY_VIEW
>>>
>>> Should I create a JIRA for a new feature?  Or is this fundamentally not
>>> possible?
>>>
>>> Thanks,
>>>     Steve
>>>
>>
>>
>>
>> --
>> Thanks & Regards,
>> Anil Gupta
>>
>
>

Reply via email to