You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Ivan Kabaivanov <iv...@spartum.tech> on 2018/04/03 08:58:05 UTC

How to query cache with sql commands

Hi, ignite users.

I am a complete beginner when it comes to Apache Ignite.  I am not a java
programmer either.

I am experimenting with a simple ignite setup, latest version 2.4.0, binary
distribution on linux x86_64.  I only have one partitioned cache, called
default.  I was able to insert keys and values into it with either the REST
api or a simple python script.  I am able then to retrieve the keys via the
REST interface and I see how many keys I have via the visor
(bin/ignitevisorcmd.sh).

Parallel to that I also created a few tables and I can insert into them,
query them, etc with dbeaver, etc.

What I want: to be able to use SQL to query the cache.

Is it possible?  What do I need to add to my very basic xml?  My xml is
shown below:


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="cacheConfiguration">
            <list>
                <bean
class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="default"/>
                    <property name="cacheMode" value="PARTITIONED"/>
                    <property name="atomicityMode" value="TRANSACTIONAL"/>
                    <property name="writeSynchronizationMode"
value="FULL_SYNC"/>
                    <property name="backups" value="1"/>
                </bean>
            </list>
        </property>

        <!-- Explicitly configure TCP discovery SPI to provide list of
initial nodes. -->
        <property name="discoverySpi">
            <bean
class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1:47500..47509</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
</beans>

Thanks,
IvanK.

Re: How to query cache with sql commands

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello Ivan!

Note that you can also call setQueryEntities() from Java code, or add
indexedTypes to XML file! You should have complete freedom here.

Regards,

-- 
Ilya Kasnacheev

2018-04-03 14:18 GMT+03:00 Denis Mekhanikov <dm...@gmail.com>:

> Hi Ivan!
>
> You should also add *QueryEntity* configuration to XML file, or use
> *CacheConfiguration#setIndexedTypes()* method from Java code.
> After that you will be able to query data, that was added to your caches.
> And you won't actually need to create tables, using DDL, they will be
> created by Ignite, based on the cache configuration.
> Refer to the following documentation page for more information, especially
> last two sections: https://apacheignite.readme.io/docs/cache-queries
>
> Denis
>
> вт, 3 апр. 2018 г. в 11:58, Ivan Kabaivanov <iv...@spartum.tech>
> :
>
>> Hi, ignite users.
>>
>> I am a complete beginner when it comes to Apache Ignite.  I am not a java
>> programmer either.
>>
>> I am experimenting with a simple ignite setup, latest version 2.4.0,
>> binary distribution on linux x86_64.  I only have one partitioned cache,
>> called default.  I was able to insert keys and values into it with either
>> the REST api or a simple python script.  I am able then to retrieve the
>> keys via the REST interface and I see how many keys I have via the visor
>> (bin/ignitevisorcmd.sh).
>>
>> Parallel to that I also created a few tables and I can insert into them,
>> query them, etc with dbeaver, etc.
>>
>> What I want: to be able to use SQL to query the cache.
>>
>> Is it possible?  What do I need to add to my very basic xml?  My xml is
>> shown below:
>>
>>
>> <beans xmlns="http://www.springframework.org/schema/beans"
>>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>        xsi:schemaLocation="
>>         http://www.springframework.org/schema/beans
>>         http://www.springframework.org/schema/beans/spring-beans.xsd">
>>     <bean id="ignite.cfg" class="org.apache.ignite.configuration.
>> IgniteConfiguration">
>>         <property name="cacheConfiguration">
>>             <list>
>>                 <bean class="org.apache.ignite.configuration.
>> CacheConfiguration">
>>                     <property name="name" value="default"/>
>>                     <property name="cacheMode" value="PARTITIONED"/>
>>                     <property name="atomicityMode" value="TRANSACTIONAL"/>
>>                     <property name="writeSynchronizationMode"
>> value="FULL_SYNC"/>
>>                     <property name="backups" value="1"/>
>>                 </bean>
>>             </list>
>>         </property>
>>
>>         <!-- Explicitly configure TCP discovery SPI to provide list of
>> initial nodes. -->
>>         <property name="discoverySpi">
>>             <bean class="org.apache.ignite.spi.
>> discovery.tcp.TcpDiscoverySpi">
>>                 <property name="ipFinder">
>>                     <bean class="org.apache.ignite.spi.
>> discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
>>                         <property name="addresses">
>>                             <list>
>>                                 <value>127.0.0.1:47500..47509</value>
>>                             </list>
>>                         </property>
>>                     </bean>
>>                 </property>
>>             </bean>
>>         </property>
>>     </bean>
>> </beans>
>>
>> Thanks,
>> IvanK.
>>
>

Re: How to query cache with sql commands

Posted by Denis Mekhanikov <dm...@gmail.com>.
Hi Ivan!

You should also add *QueryEntity* configuration to XML file, or use
*CacheConfiguration#setIndexedTypes()* method from Java code.
After that you will be able to query data, that was added to your caches.
And you won't actually need to create tables, using DDL, they will be
created by Ignite, based on the cache configuration.
Refer to the following documentation page for more information, especially
last two sections: https://apacheignite.readme.io/docs/cache-queries

Denis

вт, 3 апр. 2018 г. в 11:58, Ivan Kabaivanov <iv...@spartum.tech>:

> Hi, ignite users.
>
> I am a complete beginner when it comes to Apache Ignite.  I am not a java
> programmer either.
>
> I am experimenting with a simple ignite setup, latest version 2.4.0,
> binary distribution on linux x86_64.  I only have one partitioned cache,
> called default.  I was able to insert keys and values into it with either
> the REST api or a simple python script.  I am able then to retrieve the
> keys via the REST interface and I see how many keys I have via the visor
> (bin/ignitevisorcmd.sh).
>
> Parallel to that I also created a few tables and I can insert into them,
> query them, etc with dbeaver, etc.
>
> What I want: to be able to use SQL to query the cache.
>
> Is it possible?  What do I need to add to my very basic xml?  My xml is
> shown below:
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="
>         http://www.springframework.org/schema/beans
>         http://www.springframework.org/schema/beans/spring-beans.xsd">
>     <bean id="ignite.cfg"
> class="org.apache.ignite.configuration.IgniteConfiguration">
>         <property name="cacheConfiguration">
>             <list>
>                 <bean
> class="org.apache.ignite.configuration.CacheConfiguration">
>                     <property name="name" value="default"/>
>                     <property name="cacheMode" value="PARTITIONED"/>
>                     <property name="atomicityMode" value="TRANSACTIONAL"/>
>                     <property name="writeSynchronizationMode"
> value="FULL_SYNC"/>
>                     <property name="backups" value="1"/>
>                 </bean>
>             </list>
>         </property>
>
>         <!-- Explicitly configure TCP discovery SPI to provide list of
> initial nodes. -->
>         <property name="discoverySpi">
>             <bean
> class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
>                 <property name="ipFinder">
>                     <bean
> class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
>                         <property name="addresses">
>                             <list>
>                                 <value>127.0.0.1:47500..47509</value>
>                             </list>
>                         </property>
>                     </bean>
>                 </property>
>             </bean>
>         </property>
>     </bean>
> </beans>
>
> Thanks,
> IvanK.
>