You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by gj...@apache.org on 2020/03/23 21:16:03 UTC

[phoenix] branch 4.x updated: PHOENIX-5785 - Remove TTL check in QueryCompiler when doing an SCN / Lookback query

This is an automated email from the ASF dual-hosted git repository.

gjacoby pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x by this push:
     new d961940  PHOENIX-5785 - Remove TTL check in QueryCompiler when doing an SCN / Lookback query
d961940 is described below

commit d961940d1463e575924a4cd09fee5628ea60c1bf
Author: Geoffrey Jacoby <gj...@apache.org>
AuthorDate: Fri Mar 20 13:15:25 2020 -0700

    PHOENIX-5785 - Remove TTL check in QueryCompiler when doing an SCN / Lookback query
---
 .../it/java/org/apache/phoenix/end2end/SCNIT.java  | 32 ----------------------
 .../org/apache/phoenix/compile/QueryCompiler.java  | 30 --------------------
 2 files changed, 62 deletions(-)

diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java
index 8512028..0210df2 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java
@@ -27,11 +27,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Properties;
 
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.regionserver.ScanInfoUtil;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
-import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
-import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.SchemaUtil;
 import org.junit.Assert;
@@ -102,34 +98,6 @@ public class SCNIT extends ParallelStatsDisabledIT {
 		}
 	}
 
-	@Test
-	public void testTooLowSCNWithTTL() throws Exception {
-		//if scn is for an older time than a table's ttl, it should throw a SQLException
-		int ttl = 2;
-		String fullTableName = createTableWithTTL(ttl);
-		int sleepTime = (ttl + 1)* 1000;
-		//need to sleep long enough for the SCN to still find the syscat row for the table
-		Thread.sleep(sleepTime);
-		Properties props = new Properties();
-		props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB,
-			Long.toString(EnvironmentEdgeManager.currentTime() - sleepTime));
-		try (Connection connscn = DriverManager.getConnection(getUrl(), props)) {
-			connscn.createStatement().
-				executeQuery(String.format("select * from %s", fullTableName));
-		} catch (SQLException se){
-			SQLExceptionCode code = SQLExceptionCode.CANNOT_QUERY_TABLE_WITH_SCN_OLDER_THAN_TTL;
-			assertSqlExceptionCode(code, se);
-			return;
-		}
-		Assert.fail("We should have thrown an exception for the too-early SCN");
-	}
-
-	private void assertSqlExceptionCode(SQLExceptionCode code, SQLException se) {
-		assertEquals(code.getErrorCode(), se.getErrorCode());
-		assertTrue("Wrong error message", se.getMessage().contains(code.getMessage()));
-		assertEquals(code.getSQLState(), se.getSQLState());
-	}
-
 	private String createTableWithTTL(int ttl) throws SQLException, InterruptedException {
 		String schemaName = generateUniqueName();
 		String tableName = generateUniqueName();
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
index a7b6948..2cf9b10 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java
@@ -28,8 +28,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.regionserver.ScanInfoUtil;
 import org.apache.hadoop.hbase.util.Pair;
@@ -74,7 +72,6 @@ import org.apache.phoenix.parse.SelectStatement;
 import org.apache.phoenix.parse.SubqueryParseNode;
 import org.apache.phoenix.parse.TableNode;
 import org.apache.phoenix.query.ConnectionQueryServices;
-import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
 import org.apache.phoenix.schema.AmbiguousColumnException;
@@ -176,10 +173,8 @@ public class QueryCompiler {
         if (scn == null) {
             return;
         }
-        List<TableRef> scnTooOldTableRefs = new ArrayList<TableRef>();
         ColumnResolver resolver =
             FromCompiler.getResolverForQuery(select, conn);
-        List<TableRef> involvedTables = resolver.getTables();
         int maxLookBackAge = conn.getQueryServices().
             getConfiguration().getInt(ScanInfoUtil.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY,
             ScanInfoUtil.DEFAULT_PHOENIX_MAX_LOOKBACK_AGE);
@@ -189,31 +184,6 @@ public class QueryCompiler {
                 SQLExceptionCode.CANNOT_QUERY_TABLE_WITH_SCN_OLDER_THAN_MAX_LOOKBACK_AGE)
                 .build().buildException();
         }
-        for (TableRef tableRef : involvedTables) {
-            byte[] tableQualifier = tableRef.getTable().getPhysicalName().getBytes();
-            //we can have a tableRef with an empty table, such as with sequences
-            if (tableQualifier.length > 0) {
-                HTableDescriptor td = conn.getQueryServices().getTableDescriptor(tableQualifier);
-                HColumnDescriptor[] cds = td.getColumnFamilies();
-                now = EnvironmentEdgeManager.currentTimeMillis();
-                if (cds.length > 0){
-                    //Phoenix only allows a single table level TTL, so any CF will do
-                    if (now - cds[0].getTimeToLive() * 1000L > scn) {
-                        scnTooOldTableRefs.add(tableRef);
-                    }
-                }
-            }
-        }
-        if (scnTooOldTableRefs.size() > 0) {
-            TableRef tableRef = scnTooOldTableRefs.get(0);
-            throw new SQLExceptionInfo.Builder(
-                SQLExceptionCode.CANNOT_QUERY_TABLE_WITH_SCN_OLDER_THAN_TTL)
-                .setSchemaName(tableRef.getTable().getSchemaName().getString())
-                .setTableName(tableRef.getTable().getTableName().getString())
-                .build()
-                .buildException();
-        }
-
     }
 
     public QueryPlan compileUnionAll(SelectStatement select) throws SQLException {