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

James Taylor commented on PHOENIX-3298:
---------------------------------------

The ColumnDef object in Phoenix declares isNull as Boolean:
{code}
public class ColumnDef {
    private final ColumnName columnDefName;
    private final PDataType dataType;
    private final Boolean isNull;
    private final Integer maxLength;
    private final Integer scale;
    private boolean isPK;
    private final SortOrder sortOrder;
    private final boolean isArray;
    private final Integer arrSize;
    private final String expressionStr;
    private final boolean isRowTimestamp;

    ColumnDef(ColumnName columnDefName, String sqlTypeName, boolean isArray, 
Integer arrSize, Boolean isNull, Integer maxLength,
            Integer scale, boolean isPK, SortOrder sortOrder, String 
expressionStr, boolean isRowTimestamp) {
{code}

We've got the following code in MetaDataClient that will flag the problematic 
declaration:
{code}
            if (isPK && !addingToPK && pkConstraint.getColumnNames().size() <= 
1) {
                if (def.isNull() && def.isNullSet()) {
                    throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.SINGLE_PK_MAY_NOT_BE_NULL)
                    .setColumnName(columnName).build().buildException();
                }
                isNull = false;
            }
{code}

Can we declare the isNull as Boolean in parserImpls.ftl and leave it as null if 
not set? Is SqlColumnDefNode derived from ColumnDef or does a translation occur 
to it? Either way, if the ColumnDef isNull Boolean is set appropriately (null, 
true, or false), I don't think there'll be an issue.

> 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
>         Attachments: PHOENIX-3298-WIP
>
>
> 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