gjacoby126 commented on a change in pull request #935: URL: https://github.com/apache/phoenix/pull/935#discussion_r513080370
########## File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java ########## @@ -910,6 +911,48 @@ public void testTableDescriptorPriority() throws SQLException, IOException { } } + @Test + public void testCreateTableDDLTimestamp() throws Exception { + Properties props = new Properties(); + final String schemaName = generateUniqueName(); + final String tableName = generateUniqueName(); + final String dataTableFullName = SchemaUtil.getTableName(schemaName, tableName); + String ddl = + "CREATE TABLE " + dataTableFullName + " (\n" + "ID1 VARCHAR(15) NOT NULL,\n" + + "ID2 VARCHAR(15) NOT NULL,\n" + "CREATED_DATE DATE,\n" + + "CREATION_TIME BIGINT,\n" + "LAST_USED DATE,\n" + + "CONSTRAINT PK PRIMARY KEY (ID1, ID2)) "; + long startTS = EnvironmentEdgeManager.currentTimeMillis(); + try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + conn.createStatement().execute(ddl); + verifyLastDDLTimestamp(schemaName, tableName, dataTableFullName, startTS, conn); + } + } + + public static long verifyLastDDLTimestamp(String schemaName, String tableName, + String dataTableFullName, long startTS, Connection conn) throws SQLException { + long endTS = EnvironmentEdgeManager.currentTimeMillis(); + //First try the JDBC metadata API + PhoenixDatabaseMetaData metadata = (PhoenixDatabaseMetaData) conn.getMetaData(); + ResultSet rs = metadata.getTables("", schemaName, tableName, null); + assertTrue("No metadata returned", rs.next()); + Long ddlTimestamp = rs.getLong(PhoenixDatabaseMetaData.LAST_DDL_TIMESTAMP); + assertNotNull("JDBC DDL timestamp is null!", ddlTimestamp); + assertTrue("JDBC DDL Timestamp not in the right range!", + ddlTimestamp >= startTS && ddlTimestamp <= endTS); + //Now try the PTable API + PTable table = PhoenixRuntime.getTableNoCache(conn, dataTableFullName); Review comment: Done. ########## File path: phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java ########## @@ -107,6 +107,18 @@ HColumnDescriptor.KEEP_DELETED_CELLS, HColumnDescriptor.REPLICATION_SCOPE); + public static Mutation getLastDDLTimestampUpdate(byte[] tableHeaderRowKey, Review comment: Done ---------------------------------------------------------------- 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: us...@infra.apache.org