yanxinyi 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_r342298030
##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java
##########
@@ -107,34 +140,258 @@ public void
testWithBasicGlobalViewWithNoViewTTLDefined() throws Exception {
.withGlobalViewDefaults()
.build();
- // Define the test data.
- PhoenixTestBuilder.DataSupplier dataSupplier = new
PhoenixTestBuilder.DataSupplier() {
- // Create an unique ORG_ID of type char(15).
- final String
- orgId =
- String.format(ORG_ID_FMT,
schemaBuilder.getDataOptions().getUniqueName());
- final String kp =
SchemaUtil.normalizeIdentifier(schemaBuilder.getEntityKeyPrefix());
-
- @Override public List<Object> getValues(int rowIndex) {
- // Create an ID of type char(15).
- String id = String.format(ID_FMT, rowIndex);
- return Lists.newArrayList(new Object[] { orgId, kp, id });
- }
- };
+ // Expected 2 rows - one for Table and GlobalView each.
+ // Since the VIEW_TTL property values are not being set, we expect the
view header columns to show up in raw scans only.
+
assertViewHeaderRowsHaveViewTTLRelatedCells(schemaBuilder.getTableOptions().getSchemaName(),
startTime, true, 2);
+ }
- // Create a test data writer for the above schema.
- PhoenixTestBuilder.DataWriter dataWriter = new
PhoenixTestBuilder.BasicDataWriter();
- try (Connection connection = DriverManager.getConnection(getUrl())) {
- connection.setAutoCommit(true);
- dataWriter.setConnection(connection);
- dataWriter.setDataSupplier(dataSupplier);
- dataWriter.setUpsertColumns(Lists.newArrayList("OID", "KP", "ID"));
-
dataWriter.setTargetEntity(schemaBuilder.getEntityGlobalViewName());
+
+ @Test
+ public void testViewTTLWithTableLevelTTLFails() throws Exception {
+
+ // Define the test schema.
+ // 1. Table with default columns => (ORG_ID, KP, COL1, COL2, COL3), PK
=> (ORG_ID, KP)
+ // 2. Tenant with default columns => (ZID, COL7, COL8, COL9), PK =>
(ZID)
+ final PhoenixTestBuilder.SchemaBuilder schemaBuilder = new
PhoenixTestBuilder.SchemaBuilder(getUrl());
+
+ TableOptions tableOptions = TableOptions.withDefaults();
+
tableOptions.setTableProps("COLUMN_ENCODED_BYTES=0,MULTI_TENANT=true,TTL=100");
+
+ TenantViewOptions tenantViewOptions = TenantViewOptions.withDefaults();
+ tenantViewOptions.setTableProps("VIEW_TTL=1000");
+ try {
+ schemaBuilder
+ .withTableOptions(tableOptions)
+ .withTenantViewOptions(tenantViewOptions)
+ .buildNewView();
+ fail();
+ } catch (SQLException e) {
+
assertEquals(SQLExceptionCode.CANNOT_SET_OR_ALTER_VIEW_TTL_FOR_TABLE_WITH_TTL.getErrorCode(),
e.getErrorCode());
Review comment:
what if we don't get exception? Maybe using a flag to indicate we do have
this exception?
----------------------------------------------------------------
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