Mikhail Petrov created IGNITE-17041:
---------------------------------------
Summary: Normalize query entity after it is modified during merge
process.
Key: IGNITE-17041
URL: https://issues.apache.org/jira/browse/IGNITE-17041
Project: Ignite
Issue Type: Bug
Reporter: Mikhail Petrov
It is needed to to normalize query entity after it is modified during MERGE
process as it is done during the first cache configuration processing.
Currently new table columns that was created based on Query Entity fields which
was added during MERGE process has the naming that differs from columns that
were created based on initial Query Entity fields.
For example if CacheConfiguration#isSqlEscapeAll flag is disabled - all
QueryEntity fields are converted to upper case and used as such to name
columns. But it does not happen if Query Entity field was added during MERGE
process. It confuses users and leads to the situations when column conflicts
cannot be found because column names are different.
Reproducer:
{code:java}
public class TestClass extends GridCommonAbstractTest {
/**
* Start cluster nodes.
*/
public static final int NODES_CNT = 2;
/**
* Count of backup partitions.
*/
public static final int BACKUPS = 2;
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName)
throws Exception {
QueryEntity queryEntity = new QueryEntity(String.class, Person.class)
.setTableName("PERSON")
.addQueryField("id", Boolean.class.getName(), null)
.addQueryField("name", String.class.getName(), null);
CacheConfiguration<?, ?> configuration = new
CacheConfiguration<>(GridAbstractTest.DEFAULT_CACHE_NAME)
.setBackups(BACKUPS)
.setQueryEntities(Collections.singletonList(queryEntity));
if (igniteInstanceName.endsWith("1"))
queryEntity.addQueryField("age", Boolean.class.getName(), null);
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName)
.setConsistentId(igniteInstanceName)
.setDataStorageConfiguration(new DataStorageConfiguration()
.setDefaultDataRegionConfiguration(new
DataRegionConfiguration()))
.setCacheConfiguration(
configuration);
return cfg;
}
/**
* {@inheritDoc}
*/
@Override
protected void afterTest() throws Exception {
stopAllGrids();
}
/**
*
*/
@Test
public void testIssue() throws Exception {
startGrid(0);
grid(0);
grid(0).cache(GridAbstractTest.DEFAULT_CACHE_NAME).query(new
SqlFieldsQuery("ALTER TABLE PERSON ADD age INTEGER")).getAll();
GridTestUtils.assertThrows(log, () -> startGrid(1), Exception.class,
"");
grid(0).cluster().state(ClusterState.INACTIVE);
startGrid(1);
grid(0).cluster().state(ClusterState.ACTIVE);
System.out.println(grid(0).cache(DEFAULT_CACHE_NAME).query(new
SqlFieldsQuery("select * from \"SYS\".TABLE_COLUMNS"))
.getAll());
}
class Person {
private int id;
private String name;
private boolean age;
}
}
{code}
As a result we can see that "age" column is duplicated in UPPER and CAMEL case.
And no conflicts were found.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)