gjacoby126 commented on a change in pull request #1216:
URL: https://github.com/apache/phoenix/pull/1216#discussion_r626169950
##########
File path:
phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java
##########
@@ -1166,6 +1166,31 @@ public void testTableDescriptorPriority() throws
SQLException, IOException {
}
}
+ @Test
+ public void testCreateTableSchemaVersion() throws Exception {
+ Properties props = new Properties();
+ final String schemaName = generateUniqueName();
+ final String tableName = generateUniqueName();
+ final String version = "V1.0";
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ testCreateTableSchemaVersionHelper(conn, schemaName, tableName,
version);
+ }
+ }
+
+ public static void testCreateTableSchemaVersionHelper(Connection conn,
String schemaName, String tableName,
+ String
dataTableVersion)
+ throws Exception {
+ final String dataTableFullName = SchemaUtil.getTableName(schemaName,
tableName);
+ String ddl =
+ "CREATE TABLE " + dataTableFullName + " (\n" + "ID1
VARCHAR(15) NOT NULL,\n"
Review comment:
I disagree that schema version should auto-increment. First, because an
auto-incrementing int sequence already exists (see PTable.getSequenceNumber,
which gets incremented by DDL statements), and second, because that's not
really what this feature is meant to do.
The purpose of SCHEMA_VERSION is that it's a string which is relevant to a
particular client application or applications and its release numbering.
Say application Foo has quarterly releases "Q1-2021", "Q1-2021.1",
"Q2-2021", and so on. It creates tables A, B, and C as part of Q1-2021, makes a
table property change to table B during Q1-2021.1, and then adds 2 more tables
D and E and 1 column to an existing table C in Q2-2021.
At this point the schema versions are:
A: Q1-2021
B: Q1-2021.1
C: Q2-2021 (assuming there was a separate statement to update schema version
after adding the column)
D: Q2-2021
E: Q2-2021
From this, the application Foo can check for each table that its schema
version is the version that it expects (or not) and take action accordingly. An
application running Q1-2021 can still interpret queries / messages against
Table A, but might want to reject ones from tables B through E, because they're
from newer schemas that it has no knowledge of.
--
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]