[ 
https://issues.apache.org/jira/browse/PHOENIX-3298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15523313#comment-15523313
 ] 

Eric Lomore commented on PHOENIX-3298:
--------------------------------------

Before I finish up on this, I wanted to find out the desired functionality for 
a case like the one below. Do we want to still throw an error for explicit 
(incorrect) null declarations or is it okay to also convert this to not null, 
maybe with some type of warning posted?
If we do want to still throw an error for this statement, I believe a small 
grammar change would be necessary to add a field indicating whether "isNull" is 
explicitly or implicitly set in SqlOptionNode.

  {code} @Test
    public void testInvalidPrimaryKeyDecl() throws Exception {
        String[] queries = {
                "CREATE TABLE t (k varchar null primary key)",
                "CREATE TABLE t (k varchar null, constraint pk primary key 
(k))",
        };
        Connection conn = DriverManager.getConnection(getUrl());
        for (String query : queries) {
            try {
                conn.createStatement().execute(query);
                fail("Compilation should have failed since this is an invalid 
PRIMARY KEY declaration: " + query);
            } catch (SQLException e) {
                System.out.println(e.getMessage());
                assertEquals(query, 
SQLExceptionCode.SINGLE_PK_MAY_NOT_BE_NULL.getErrorCode(), e.getErrorCode());
            }
        }
    }{code}

> Create Table: Single column primary key may not be null
> -------------------------------------------------------
>
>                 Key: PHOENIX-3298
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3298
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Eric Lomore
>            Assignee: Eric Lomore
>
> Create table statements with a single column currently must have "NOT NULL" 
> identifier to pass tests.
> Running this code results in failure
> {code}CREATE TABLE t (k VARCHAR PRIMARY KEY DESC){code}
> While this allows tests to pass
> {code}CREATE TABLE t (k VARCHAR NOT NULL PRIMARY KEY DESC){code}
> Must either enforce the not null condition and update test cases, or apply a 
> fix.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to