- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Phoenix: how to make regex on field?
- Labels:
-
Apache Phoenix
Created ‎08-09-2016 07:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a phoenix view on an existing hbase table. I don't find in the documentation how to select every lines of a table where the column "name" match with a specific regex or function on string like contain, start with, etc. For example in "traditional sql": select name,phone from table1 where like "%ab%; or every ligne with a rowkey that start with "blabla".
Thanks in advance to point me how to do it easily (I hope that's not needed to use UDF...)
Michel
Created ‎08-09-2016 07:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See http://phoenix.apache.org/language/index.html#condition. Your "traditional sql" approach works with Apache Phoenix.
> create table foo(s varchar, pk integer not null primary key); > upsert into foo values('abcd_bar', 1); > upsert into foo values('dcba_bar', 2); > select * from foo where s like 'abcd%';
This will return
+-----------+-----+ | S | PK | +-----------+-----+ | abcd_bar | 1 | +-----------+-----+
Created ‎08-09-2016 07:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See http://phoenix.apache.org/language/index.html#condition. Your "traditional sql" approach works with Apache Phoenix.
> create table foo(s varchar, pk integer not null primary key); > upsert into foo values('abcd_bar', 1); > upsert into foo values('dcba_bar', 2); > select * from foo where s like 'abcd%';
This will return
+-----------+-----+ | S | PK | +-----------+-----+ | abcd_bar | 1 | +-----------+-----+
Created ‎08-09-2016 07:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok super thanks, I didn't try because it was not refer in the documentation that the function like work. 🙂
Created ‎08-09-2016 07:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Michel Sumbul you may find all functions here https://phoenix.apache.org/language/functions.html and of course you may use 'like' keyword, so it will be as a regular sql query:
select name, phone from table1 where name like '%Smith%'
Created ‎02-22-2017 06:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Now if table has records like
- +-----------+-----+
- | S | PK |
- +-----------+-----+
- | abcd_bar |1|
- +-----------+-----+
- | 1234_bar |1|
- +-----------+-----+
And i want to search only 1234_bar(starting with digits), then how should i write the queries in Phoenix.
,If Table records are like
- +-----------+-----+
- | S | PK |
- +-----------+-----+
- | 1234_bar |1|
- +-----------+-----+
- | test_bar |2|
- +-----------+-----+
And now if i want to search only 1234_bar then how should i write Select query ?
Created ‎02-22-2017 03:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do not piggy-back on others' questions which have already been answered, please. Ask your own question.
