ChinmaySKulkarni commented on a change in pull request #599: Create columns in 
SYSCAT and fields in PTable.proto for view TTL support
URL: https://github.com/apache/phoenix/pull/599#discussion_r336663775
 
 

 ##########
 File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java
 ##########
 @@ -0,0 +1,111 @@
+package org.apache.phoenix.end2end;
+
+import com.google.common.collect.Lists;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.filter.*;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.query.PhoenixTestBuilder;
+import org.apache.phoenix.query.QueryConstants;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class ViewTTLIT extends ParallelStatsDisabledIT {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(ViewTTLIT.class);
+
+    // Scans the HBase rows directly for the view ttl related header rows 
column and asserts
+    private void assertViewHeaderRowsHaveViewTTLRelatedCells(String 
schemaName, long minTimestamp,
+            int expectedRows) throws IOException, SQLException {
+
+        FilterList filterList = new 
FilterList(FilterList.Operator.MUST_PASS_ALL);
+        RowFilter schemaNameFilter = new RowFilter(
+                CompareFilter.CompareOp.EQUAL,
+                new SubstringComparator(schemaName)
+        );
+        ColumnPrefixFilter viewTTLPrefixFilter = new 
ColumnPrefixFilter(PhoenixDatabaseMetaData.VIEW_TTL_BYTES);
+        filterList.addFilter(schemaNameFilter);
+        filterList.addFilter(viewTTLPrefixFilter);
+        try (Table tbl = driver.getConnectionQueryServices(getUrl(), 
TestUtil.TEST_PROPERTIES)
+                .getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES)) {
+
+            Scan allRows = new Scan();
+            allRows.setRaw(true);
+            allRows.setTimeRange(minTimestamp, HConstants.LATEST_TIMESTAMP);
+            allRows.setFilter(filterList);
+            ResultScanner scanner = tbl.getScanner(allRows);
+            int numMatchingRows = 0;
+            for (Result result = scanner.next(); result != null; result = 
scanner.next()) {
+                numMatchingRows +=
+                        
result.containsColumn(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES,
+                                PhoenixDatabaseMetaData.VIEW_TTL_BYTES) ? 1 : 
0;
+            }
+            assertEquals(String.format("Expected rows do match for table = %s 
at timestamp %d",
+                    
Bytes.toString(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES), 
minTimestamp), expectedRows, numMatchingRows);
+        }
+
+    }
+
+    /**
+         * -----------------
+         * Test methods
+         * -----------------
+         */
+
+    @Test
+    public void testWithBasicTenantViewWithNoViewTTLDefined() throws Exception 
{
 
 Review comment:
   I guess that will be a TODO..?

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to