You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Evgenii Zhuravlev (JIRA)" <ji...@apache.org> on 2019/02/06 02:07:00 UTC

[jira] [Created] (IGNITE-11219) CREATE TABLE with template doesn't work properly with data inserted from KV API

Evgenii Zhuravlev created IGNITE-11219:
------------------------------------------

             Summary: CREATE TABLE with template doesn't work properly with data inserted from KV API
                 Key: IGNITE-11219
                 URL: https://issues.apache.org/jira/browse/IGNITE-11219
             Project: Ignite
          Issue Type: Bug
            Reporter: Evgenii Zhuravlev


When you use a template for your table, it takes the affinityMapper field from this template, which was set for a different type without any keyConfigurations. This leads to the problem with accessing data  from SQL if it was inserted using Key-value API

Here is a code to reproduce the issue:
{code:java}
 Ignition.setClientMode(true);
        Ignite ignite = Ignition.start("examples/config/example-ignite.xml");
        ignite.cluster().active(true);
        IgniteCache cache = ignite.getOrCreateCache("test");

        cache.query(new SqlFieldsQuery("CREATE TABLE IF NOT EXISTS TEST\n" +
            "(\n" +
            "  TEST_ID                NUMBER(15)        NOT NULL,\n" +
            "  TEST_FIELD             VARCHAR2(100),\n" +
            "  PRIMARY KEY (TEST_ID)\n" +
            ") with \"TEMPLATE=TEST_TEMPLATE,KEY_TYPE=TEST_KEY ,CACHE_NAME=TEST_CACHE , VALUE_TYPE=TEST_VALUE,ATOMICITY=TRANSACTIONAL\";").setSchema("PUBLIC"));


        for (int i = 0; i < 100; i++) {
            BinaryObjectBuilder keyBuilder = ignite.binary().builder("TEST_KEY");


            keyBuilder.setField("TEST_ID", new BigDecimal(111111111111111l + i));

            BinaryObjectBuilder valueBuilder = ignite.binary().builder("TEST_VALUE");

            valueBuilder.setField("TEST_FIELD", "123123" + i);


            ignite.cache("TEST_CACHE").withKeepBinary().put(keyBuilder.build(), valueBuilder.build());

        }

        System.out.println("FOUND:" + ignite.cache("TEST_CACHE").query(new SqlFieldsQuery("Select * from TEST")).getAll().size());

        System.out.println("FOUND:" + ignite.cache("TEST_CACHE").query(new SqlFieldsQuery("Select TEST_FIELD from TEST where TEST_ID = 111111111111111")).getAll());

        for (int i = 0; i < 100; i++)
            System.out.println("FOUND:" + ignite.cache("TEST_CACHE").query(new SqlFieldsQuery("Select TEST_FIELD from TEST where TEST_ID  = " + (111111111111111l + i))).getAll());
{code}

Here is a test template:
{code:java}
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="TEST_TEMPLATE*"/>
                </bean>
{code}

Steps to reproduce:
1. Start a server node, for example, using ExampleNodeStartup.
2. Start a client node using the code provided above with the template in configuration.


Possible quickfix:

set affinityMapper to cfgTemplate in GridCacheProcessor.getConfigFromTemplate:
cfgTemplate.setAffinityMapper(null)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)