haridsv commented on code in PR #1866: URL: https://github.com/apache/phoenix/pull/1866#discussion_r1562001629
########## phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCDefinitionIT.java: ########## @@ -0,0 +1,328 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.end2end; + +import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.schema.PColumn; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.util.CDCUtil; +import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.SchemaUtil; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; + +import static org.apache.phoenix.schema.PTable.QualifierEncodingScheme.NON_ENCODED_QUALIFIERS; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +@RunWith(Parameterized.class) +@Category(ParallelStatsDisabledTest.class) +public class CDCDefinitionIT extends CDCBaseIT { + private final boolean forView; + + public CDCDefinitionIT(boolean forView) { + this.forView = forView; + } + + @Parameterized.Parameters(name = "forView={0}") + public static synchronized Collection<Boolean[]> data() { + return Arrays.asList(new Boolean[][] { + { false}, { true } + }); + } + + @Test + public void testCreate() throws Exception { + Connection conn = newConnection(); + String tableName = generateUniqueName(); + String datatableName = tableName; + conn.createStatement().execute( + "CREATE TABLE " + tableName + " ( k INTEGER PRIMARY KEY," + " v1 INTEGER," + + " v2 DATE)"); + if (forView) { + String viewName = generateUniqueName(); + conn.createStatement().execute( + "CREATE VIEW " + viewName + " AS SELECT * FROM " + tableName); + tableName = viewName; + } + String cdcName = generateUniqueName(); + String cdc_sql; + + try { + conn.createStatement().execute("CREATE CDC " + cdcName + + " ON NON_EXISTENT_TABLE"); + fail("Expected to fail due to non-existent table"); + } catch (SQLException e) { + assertEquals(SQLExceptionCode.TABLE_UNDEFINED.getErrorCode(), e.getErrorCode()); + } + + cdc_sql = "CREATE CDC " + cdcName + " ON " + tableName; + createCDCAndWait(conn, tableName, cdcName, cdc_sql, null, null, null); + assertCDCState(conn, cdcName, null, 3); + assertNoResults(conn, cdcName); + + try { + conn.createStatement().execute(cdc_sql); Review Comment: Yes, the CDC objects are completely independent of each other, with their own change scopes, so they can use same or different change scopes. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
