[ 
https://issues.apache.org/jira/browse/PHOENIX-7040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17782801#comment-17782801
 ] 

ASF GitHub Bot commented on PHOENIX-7040:
-----------------------------------------

jpisaac commented on code in PR #1710:
URL: https://github.com/apache/phoenix/pull/1710#discussion_r1382298507


##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/TTLAsPhoenixTTLIT.java:
##########
@@ -370,4 +455,62 @@ private String createViewOnViewWithTTL(Connection conn, 
String parentViewName,
         return childView;
     }
 
+

Review Comment:
   You may need to add tests for resetting TTL (TTL=NONE) at a given level and 
then setting (ALTER) to new TTL at a different level.
   
   Currently Alter table  TTL=NONE sets it to 0 and thus cannot set a new TTL 
at a different level.



##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewMetadataIT.java:
##########
@@ -63,6 +63,7 @@
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.commons.lang3.mutable.MutableBoolean;

Review Comment:
   nit: Unused imports



##########
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java:
##########
@@ -19,78 +19,20 @@
 
 import static org.apache.hadoop.hbase.KeyValueUtil.createFirstOnRow;
 import static 
org.apache.phoenix.coprocessor.generated.MetaDataProtos.MutationCode.UNABLE_TO_CREATE_CHILD_LINK;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.APPEND_ONLY_SCHEMA_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ARRAY_SIZE_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.AUTO_PARTITION_SEQ_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CLASS_NAME_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_COUNT_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_DEF_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_QUALIFIER_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_QUALIFIER_COUNTER_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_SIZE_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TABLE_NAME_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TYPE_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DECIMAL_DIGITS_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_VALUE_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DISABLE_WAL_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ENCODING_SCHEME_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.EXTERNAL_SCHEMA_ID_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_ROWS_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_DISABLE_TIMESTAMP_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_TYPE_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_ARRAY_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_CONSTANT_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_NAMESPACE_MAPPED_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_ROW_TIMESTAMP_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IS_VIEW_REFERENCED_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.JAR_PATH_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LAST_DDL_TIMESTAMP_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LINK_TYPE_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MAX_VALUE_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MIN_VALUE_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MULTI_TENANT_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NULLABLE_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NUM_ARGS_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TTL_NOT_DEFINED;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PHYSICAL_TABLE_NAME_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PK_NAME_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.RETURN_TYPE_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ROW_KEY_PREFIX_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SCHEMA_VERSION_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SORT_ORDER_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.STORAGE_SCHEME_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.STORE_NULLS_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.STREAMING_TOPIC_NAME_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CHILD_LINK_NAME_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TRANSACTIONAL_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TRANSACTION_PROVIDER_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TTL_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TYPE_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.UPDATE_CACHE_FREQUENCY_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.USE_STATS_FOR_PARALLELIZATION_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_CONSTANT_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_INDEX_ID_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_INDEX_ID_DATA_TYPE_BYTES;
-import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_STATEMENT_BYTES;
-import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE_BYTES;
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.*;

Review Comment:
   nit: removed .* imports



##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewUtilIT.java:
##########
@@ -17,6 +17,7 @@
  */
 package org.apache.phoenix.end2end;
 
+import org.apache.commons.lang3.mutable.MutableBoolean;

Review Comment:
   nit: Unused imports



##########
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java:
##########
@@ -629,6 +542,11 @@ public void start(CoprocessorEnvironment env) throws 
IOException {
         Tracing.addTraceMetricsSource();
         Metrics.ensureConfigured();
         metricsSource = 
MetricsMetadataSourceFactory.getMetadataMetricsSource();
+
+        //should I load it here or everytime in get TableFromCells.

Review Comment:
   Getting a Table is a light weight operation. See conn.getTable() help
   "This is a lightweight operation, pooling or caching of the returned Table 
is neither required nor desired."



##########
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java:
##########
@@ -681,6 +599,13 @@ public void getTable(RpcController controller, 
GetTableRequest request,
                     table = ViewUtil.addDerivedColumnsFromParent(connection, 
table, pTable);
                 }
             }
+//
+//            if (table.getType() == PTableType.INDEX) {
+//                try (PhoenixConnection connection = 
QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class))
 {
+//                    PTable pTable = 
PhoenixRuntime.getTableNoCache(connection, table.getParentName().getString());

Review Comment:
   nit : remove commented code



##########
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java:
##########
@@ -1400,12 +1325,23 @@ private PTable getTableFromCells(List<Cell> 
tableCellList, List<List<Cell>> allC
         builder.setStreamingTopicName(streamingTopicName != null ? 
streamingTopicName :
             oldTable != null ? oldTable.getStreamingTopicName() : null);
 
+
         Cell ttlKv = tableKeyValues[TTL_INDEX];
         int ttl = ttlKv == null ? TTL_NOT_DEFINED : PInteger.INSTANCE
                 .getCodec().decodeInt(ttlKv.getValueArray(),
                         ttlKv.getValueOffset(), SortOrder.getDefault());
-        builder.setTTL(ttlKv != null ? ttl : oldTable != null
-                ? oldTable.getTTL() : TTL_NOT_DEFINED);
+        ttl = ttlKv != null ? ttl : oldTable != null
+                ? oldTable.getTTL() : TTL_NOT_DEFINED;
+        if (tableType == VIEW && ttl == TTL_NOT_DEFINED) {
+            //Scan SysCat to get TTL from Parent View/Table
+            byte[] viewKey = SchemaUtil.getTableKey(tenantId == null ? null : 
tenantId.getBytes(),
+                    schemaName == null ? null : schemaName.getBytes(), 
tableNameBytes);
+            dumpTable(sysCat);

Review Comment:
   nit: add TODO to remove dumpTable





> Support TTL for views using the new column TTL in SYSTEM.CATALOG
> ----------------------------------------------------------------
>
>                 Key: PHOENIX-7040
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-7040
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Jacob Isaac
>            Assignee: Lokesh Khurana
>            Priority: Major
>
> Allow views to be created with TTL specs.
> Ensure TTL is specified only once in the view hierarchy.
> Child views should inherit TTL values from their parent, when not specified 
> for the given view.
> Indexes should inherit the TTL values from the base tables/views.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to