Hi Hemambara,

Yep, I left some trash in gist [1] initially ("as address"), cleaned up.

But does it really works as you need? In previous email I meant that
the behavior is not plausible even in one node case. And the problem
here is that added column "Address.street" is not mapped to
Person.address.street Java object field! It will be a separate column
instead. If separate column is what you need then I do not understand
why you need the name "Address.street", any other same seems to do the
trick.

Did I miss something?

ср, 23 окт. 2019 г. в 00:31, Hemambara <[email protected]>:
>
> I see there are couple of issues with the test
>
> 1) cache.query(new SqlFieldsQuery("alter table Person add column
> \"Address.street\"  as street varchar"));
>    - "as" is not supported in sql. So we should remove "as street" and it
> should be like
> cache.query(new SqlFieldsQuery("alter table Person add column
> \"Address.street\"  varchar"));
>
> 2) After making above change, it will work with / with out fix. But the
> problem is with out the fix, if you have any other node joining this node,
> it will not be able to join / query
>
> I just tweaked your test code. PLease find the below one. main() is your
> test class which will start one node.
>       a) Take this example and execute main() - this will start one node
>      b) now execute @Test method, this will start another node. You will get
> attached exception ( exception.txt
> <http://apache-ignite-users.70518.x6.nabble.com/file/t2625/exception.txt>  )
> with out fix as by default it take alias as "street". But with fix it will
> pass through, as it will create alias as "Address.street"
>
> Please let me know if you need more clarification. Any quick help would be
> appreciated. Thank you!
>
>
> package my.ignite.cache.poc.index;
>
> import org.apache.ignite.Ignite;
> import org.apache.ignite.IgniteCache;
> import org.apache.ignite.Ignition;
> import org.apache.ignite.cache.query.SqlFieldsQuery;
> import org.apache.ignite.configuration.CacheConfiguration;
> import org.apache.ignite.configuration.IgniteConfiguration;
> import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
> import
> org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
> import org.junit.Test;
>
> import java.util.Collections;
>
> public class NestedIndexFieldTest {
>
>     public static void main(String args[]){
>         TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi()
>                 .setIpFinder(new
> TcpDiscoveryVmIpFinder().setAddresses(Collections.singleton("127.0.0.1:47500..47509")));
>
>         IgniteConfiguration igniteConfig = new
> IgniteConfiguration().setDiscoverySpi(discoverySpi);
>         Ignite ignite = Ignition.start(igniteConfig);
>         try{
>             IgniteCache<Object, Object> cache = ignite.createCache(new
> CacheConfiguration<>("cache")
>             .setIndexedTypes(Integer.class, Person.class));
>
>             cache.put(1, new Person("john", new Address("baker", 221)));
>
>             System.err.println(cache.query(new SqlFieldsQuery("Select * from
> Person")).getAll());
>
>             cache.query(new SqlFieldsQuery("alter table Person add column
> name varchar"));
>
>             cache.query(new SqlFieldsQuery("alter table Person add column
> address other"));
>
>             System.err.println(cache.query(new SqlFieldsQuery("Select * from
> Person")).getAll());
>
>             cache.query(new SqlFieldsQuery("alter table Person add column
> \"Address.street\"  varchar"));
>
>             System.err.println(cache.query(new SqlFieldsQuery("Select * from
> Person")).getAll());
>
>             cache.put(2, new Person("bill", new Address("green", 223)));
>
>             System.err.println(cache.query(new SqlFieldsQuery("Select * from
> Person")).getAll());
>         } catch (Exception anyEx){
>
>         }
>
>     }
>
>     @Test
>     public void test(){
>         TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi()
>                 .setIpFinder(new
> TcpDiscoveryVmIpFinder().setAddresses(Collections.singleton("127.0.0.1:47500..47509")));
>
>         IgniteConfiguration igniteConfig = new
> IgniteConfiguration().setDiscoverySpi(discoverySpi);
>
>         try(Ignite ignite = Ignition.start(igniteConfig)){
>             IgniteCache<Object, Object> cache = ignite.getOrCreateCache(new
> CacheConfiguration<>("cache")
>                     .setIndexedTypes(Integer.class, Person.class));
>
>             System.err.println(cache.query(new SqlFieldsQuery("Select * from
> Person")).getAll());
>
>         }
>
>     }
> }
>
> class Person {
>     String name;
>     Address address;
>
>     Person(String name, Address address){
>         this.name = name;
>         this.address = address;
>     }
>
>     @Override
>     public String toString() {
>         return "Person{" +
>                 "name='" + name + '\'' +
>                 ", address=" + address +
>                 '}';
>     }
> }
>
> class Address {
>     String street;
>     int number;
>
>     public Address(String street, int number){
>         this.street = street;
>         this.number = number;
>     }
>
>     @Override
>     public String toString() {
>         return "Address{" +
>                 "street='" + street + '\'' +
>                 ", number=" + number +
>                 '}';
>     }
> }
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/



-- 
Best regards,
Ivan Pavlukhin

Reply via email to