yanxinyi commented on a change in pull request #799:
URL: https://github.com/apache/phoenix/pull/799#discussion_r441048018



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java
##########
@@ -635,11 +639,52 @@ public static void 
addTagsToPutsForViewAlteredProperties(List<Mutation> tableMet
                         MetaDataEndpointImpl.VIEW_MODIFIED_PROPERTY_BYTES);
                 MetaDataUtil.conditionallyAddTagsToPutCells((Put)m,
                         PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
-                        PhoenixDatabaseMetaData.VIEW_TTL_BYTES,
-                        parentViewTTLBytes,
+                        PhoenixDatabaseMetaData.PHOENIX_TTL_BYTES,
+                        parentPhoenixTTLBytes,
                         MetaDataEndpointImpl.VIEW_MODIFIED_PROPERTY_BYTES);
             }
 
         }
     }
+
+    public static ParseNode getViewWhereWithPhoenixTTL(StatementContext 
context, PTable table)
+            throws SQLException {
+        ParseNode viewWhere = null;
+        String viewStatement = null;
+
+        // If client side masking for PHOENIX_TTL is not enabled just return.
+        if (!ScanUtil.isClientSideMaskingEnabled(context.getConnection())) {
+            return viewWhere;
+        }
+
+        String viewTTLFilterClause = context.getConnection().getSCN() == null ?
+                String.format(
+                        "((TO_NUMBER(CURRENT_TIME()) - 
TO_NUMBER(phoenix_row_timestamp())) < %d)",
+                        table.getPhoenixTTL()) :
+                String.format(
+                "((%d - TO_NUMBER(phoenix_row_timestamp())) < %d)",
+                        context.getConnection().getSCN(), 
table.getPhoenixTTL());
+
+        if (table.getViewStatement() != null) {

Review comment:
       technically we are allowing the user to create a view with `SELECT * 
FROM BASE_TABLE` without anywhere clause. Do we want to count this case? 
   Personally, I don't think anyone intentional to do this, but I will let 
@ChinmaySKulkarni to confirm we don't support this.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to