Search in sources :

Example 6 with ColumnAlreadyExistsException

use of org.apache.phoenix.schema.ColumnAlreadyExistsException in project phoenix by apache.

the class QueryCompilerTest method testDuplicatePKColumn.

@Test
public void testDuplicatePKColumn() throws Exception {
    String ddl = "CREATE TABLE t (k1 VARCHAR, k1 VARCHAR CONSTRAINT pk PRIMARY KEY(k1))";
    Connection conn = DriverManager.getConnection(getUrl());
    try {
        conn.createStatement().execute(ddl);
        fail();
    } catch (ColumnAlreadyExistsException e) {
        assertEquals("K1", e.getColumnName());
    }
}
Also used : ColumnAlreadyExistsException(org.apache.phoenix.schema.ColumnAlreadyExistsException) Connection(java.sql.Connection) PhoenixConnection(org.apache.phoenix.jdbc.PhoenixConnection) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

Example 7 with ColumnAlreadyExistsException

use of org.apache.phoenix.schema.ColumnAlreadyExistsException in project phoenix by apache.

the class QueryCompilerTest method testDuplicateKVColumn.

@Test
public void testDuplicateKVColumn() throws Exception {
    String ddl = "CREATE TABLE t (k1 VARCHAR, v1 VARCHAR, v2 VARCHAR, v1 INTEGER CONSTRAINT pk PRIMARY KEY(k1))";
    Connection conn = DriverManager.getConnection(getUrl());
    try {
        conn.createStatement().execute(ddl);
        fail();
    } catch (ColumnAlreadyExistsException e) {
        assertEquals("V1", e.getColumnName());
    }
}
Also used : ColumnAlreadyExistsException(org.apache.phoenix.schema.ColumnAlreadyExistsException) Connection(java.sql.Connection) PhoenixConnection(org.apache.phoenix.jdbc.PhoenixConnection) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

Aggregations

PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)7 ColumnAlreadyExistsException (org.apache.phoenix.schema.ColumnAlreadyExistsException)7 Connection (java.sql.Connection)5 Properties (java.util.Properties)5 Test (org.junit.Test)5 BaseConnectionlessQueryTest (org.apache.phoenix.query.BaseConnectionlessQueryTest)3 TableAlreadyExistsException (org.apache.phoenix.schema.TableAlreadyExistsException)2 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 TableExistsException (org.apache.hadoop.hbase.TableExistsException)1 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)1 Mutation (org.apache.hadoop.hbase.client.Mutation)1 MultiRowMutationEndpoint (org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint)1