You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Nan Xu <na...@gmail.com> on 2019/02/12 16:25:21 UTC

Can I query ktable/stream/store with SQL like statment.

Hi,

    Just wondering if there is a way to do a sql like "select key,
value.fieild1 from ktable where key like abc%"
    The purpose of this to select some value from a ktable without a fully
defined key.  Store.all then filter on them would be very inefficient if
store is big.

Thanks,
Nan

Re: Can I query ktable/stream/store with SQL like statment.

Posted by "Matthias J. Sax" <ma...@confluent.io>.
https://github.com/confluentinc/kafka-streams-examples

The "Music" example show how Interactive Queries work.

And of course you should read the docs.


-Matthias

On 2/13/19 6:59 AM, Nan Xu wrote:
> Range query would be enough for me, is there an example? which api I can
> call for this?
> 
> Thanks,
> Nan
> 
> On Tue, Feb 12, 2019 at 6:17 PM Matthias J. Sax <ma...@confluent.io>
> wrote:
> 
>> You could do a range query from "abc" to "abd" for example (in this
>> case, you would need to make sure to check the result form the iterator
>> and drop "abd" though).
>>
>> Note, that range queries are executed on the raw bytes. Thus, you need
>> to understand how the serializes you use work. In doubt, you may want to
>> use conservative ranges and apply a filter on the iterator to ignore
>> false positives.
>>
>> Also, this only work for prefix queries, ie, if you query with a know
>> prefix of the key.
>>
>> Hope this helps.
>>
>> -Matthias
>>
>> On 2/12/19 8:25 AM, Nan Xu wrote:
>>> Hi,
>>>
>>>     Just wondering if there is a way to do a sql like "select key,
>>> value.fieild1 from ktable where key like abc%"
>>>     The purpose of this to select some value from a ktable without a
>> fully
>>> defined key.  Store.all then filter on them would be very inefficient if
>>> store is big.
>>>
>>> Thanks,
>>> Nan
>>>
>>
>>
> 


Re: Can I query ktable/stream/store with SQL like statment.

Posted by Nan Xu <na...@gmail.com>.
Range query would be enough for me, is there an example? which api I can
call for this?

Thanks,
Nan

On Tue, Feb 12, 2019 at 6:17 PM Matthias J. Sax <ma...@confluent.io>
wrote:

> You could do a range query from "abc" to "abd" for example (in this
> case, you would need to make sure to check the result form the iterator
> and drop "abd" though).
>
> Note, that range queries are executed on the raw bytes. Thus, you need
> to understand how the serializes you use work. In doubt, you may want to
> use conservative ranges and apply a filter on the iterator to ignore
> false positives.
>
> Also, this only work for prefix queries, ie, if you query with a know
> prefix of the key.
>
> Hope this helps.
>
> -Matthias
>
> On 2/12/19 8:25 AM, Nan Xu wrote:
> > Hi,
> >
> >     Just wondering if there is a way to do a sql like "select key,
> > value.fieild1 from ktable where key like abc%"
> >     The purpose of this to select some value from a ktable without a
> fully
> > defined key.  Store.all then filter on them would be very inefficient if
> > store is big.
> >
> > Thanks,
> > Nan
> >
>
>

Re: Can I query ktable/stream/store with SQL like statment.

Posted by "Matthias J. Sax" <ma...@confluent.io>.
You could do a range query from "abc" to "abd" for example (in this
case, you would need to make sure to check the result form the iterator
and drop "abd" though).

Note, that range queries are executed on the raw bytes. Thus, you need
to understand how the serializes you use work. In doubt, you may want to
use conservative ranges and apply a filter on the iterator to ignore
false positives.

Also, this only work for prefix queries, ie, if you query with a know
prefix of the key.

Hope this helps.

-Matthias

On 2/12/19 8:25 AM, Nan Xu wrote:
> Hi,
> 
>     Just wondering if there is a way to do a sql like "select key,
> value.fieild1 from ktable where key like abc%"
>     The purpose of this to select some value from a ktable without a fully
> defined key.  Store.all then filter on them would be very inefficient if
> store is big.
> 
> Thanks,
> Nan
>