[
https://issues.apache.org/jira/browse/PHOENIX-4891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16650984#comment-16650984
]
ASF GitHub Bot commented on PHOENIX-4891:
-----------------------------------------
Github user ChinmaySKulkarni commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/363#discussion_r225356137
--- Diff:
phoenix-core/src/it/java/org/apache/phoenix/rpc/UpdateCacheIT.java ---
@@ -136,14 +137,55 @@ public void testUpdateCacheForChangingUpdateTable()
throws Exception {
try (Connection conn = DriverManager.getConnection(getUrl(),
props)) {
conn.createStatement().execute("CREATE TABLE " + fullTableName
+ TestUtil.TEST_TABLE_SCHEMA + " UPDATE_CACHE_FREQUENCY=never");
}
- helpTestUpdateCache(fullTableName, new int[] {0, 0});
+ helpTestUpdateCache(fullTableName, new int[] {0, 0}, false);
try (Connection conn = DriverManager.getConnection(getUrl(),
props)) {
conn.createStatement().execute("ALTER TABLE " + fullTableName
+ " SET UPDATE_CACHE_FREQUENCY=ALWAYS");
}
- helpTestUpdateCache(fullTableName, new int[] {1, 3});
+ helpTestUpdateCache(fullTableName, new int[] {1, 3}, false);
+ }
+
+ @Test
+ public void testUpdateCacheFreqPropagatedToIndexes() throws Exception {
+ String baseTableName = generateUniqueName();
+ String fullTableName = INDEX_DATA_SCHEMA +
QueryConstants.NAME_SEPARATOR + baseTableName;
+ String localIndex = "LOCAL_" + baseTableName;
+ String globalIndex = "GLOBAL_" + baseTableName;
+ Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ try (Connection conn = DriverManager.getConnection(getUrl(),
props)) {
+ conn.createStatement().execute("CREATE TABLE " + fullTableName
+
+ TestUtil.TEST_TABLE_SCHEMA + "
UPDATE_CACHE_FREQUENCY=never");
+
+ // Create local and global indexes on the base table
+ conn.createStatement().execute("CREATE LOCAL INDEX " +
localIndex
+ + " on " + fullTableName + " (a.date1,
b.varchar_col2)");
+ conn.createStatement().execute("CREATE INDEX " + globalIndex +
" on "
+ + fullTableName + " (a.int_col1, a.long_col1)");
+ }
+
+ // The indexes should have got the UPDATE_CACHE_FREQUENCY value of
their base table
+ helpTestUpdateCache(fullTableName, new int[] {0, 0}, false);
+ helpTestUpdateCache(INDEX_DATA_SCHEMA +
QueryConstants.NAME_SEPARATOR + localIndex,
+ new int[] {0}, true);
+ helpTestUpdateCache(INDEX_DATA_SCHEMA +
QueryConstants.NAME_SEPARATOR + globalIndex,
+ new int[] {0}, true);
+
+ // Now alter the UPDATE_CACHE_FREQUENCY value of the base table
+ try (Connection conn = DriverManager.getConnection(getUrl(),
props)) {
+ conn.createStatement()
+ .execute("ALTER TABLE " + fullTableName + " SET
UPDATE_CACHE_FREQUENCY=ALWAYS");
+ }
+ // Even the indexes should now have the modified value of
UPDATE_CACHE_FREQUENCY
+ // Note that when we query the base table, during query plan
generation, we make 2 getTable
+ // requests (to retrieve the base table) for each index of the
base table
+ helpTestUpdateCache(fullTableName, new int[] {1, 15}, false);
--- End diff --
@twdsilva when we query the base table, during query plan generation, when
we evaluate the query plan for each index of the base table, we make 2
`getTable` requests (to get the base table itself for each index of the base
table). Hence, since we have 2 indexes created on this base table, we will make
2* (number of indexes) + 1 (for the base table itself) = 5 calls. Since
`helpTestUpdateCache` does 3 select calls, the value to expect is 15.
It is another issue/discussion/possible improvement to not do the extra
`getTable` calls when evaluating the query plan for an index, but this is
consistent with the currently observed behavior.
> An index should inherit UPDATE_CACHE_FREQUENCY setting from parent table
> ------------------------------------------------------------------------
>
> Key: PHOENIX-4891
> URL: https://issues.apache.org/jira/browse/PHOENIX-4891
> Project: Phoenix
> Issue Type: Bug
> Reporter: Lars Hofhansl
> Assignee: Chinmay Kulkarni
> Priority: Minor
>
> I tried:
> # creating a table with UPDATE_CACHE_FREQUENCE > 0, then creating a local
> index on the table.
> # creating a table, then creating the local index, then altering the table
> setting UPDATE_CACHE_FREQUENCY to > 0
> In both cases the local index did not inherit the setting, verified both by
> looking at SYSTEM.CATALOG, as well by behavior.
> Update: This also happens for a global index.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)