You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Jesse Yates (JIRA)" <ji...@apache.org> on 2014/10/01 02:12:33 UTC

[jira] [Comment Edited] (PHOENIX-1305) create index throws NPE when dataTable has specified default column family

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

Jesse Yates edited comment on PHOENIX-1305 at 10/1/14 12:11 AM:
----------------------------------------------------------------

This seems more like a band-aid than the fix for the real issue (though it does fix it), which is why aren't the properties set correctly? They are going to be null unless we have fam_properties set, as from the grammar (ln 390-397):
{code}
create_index_node returns [CreateIndexStatement ret]
    :   CREATE l=LOCAL? INDEX (IF NOT ex=EXISTS)? i=index_name ON t=from_table_name
        (LPAREN pk=index_pk_constraint RPAREN)
        (INCLUDE (LPAREN icrefs=column_names RPAREN))?
        (p=fam_properties)?
        (SPLIT ON v=value_expression_list)?
        {ret = factory.createIndex(i, factory.namedTable(null,t), pk, icrefs, v, p, ex!=null, l==null ? IndexType.getDefault() : IndexType.LOCAL, getBindCount()); }
    ;
{code}

As generated in the PhoenixSQLParser (ln 1297-1305):
{code}
case 1 :
	// PhoenixSQL.g:394:10: p= fam_properties
	{
		pushFollow(FOLLOW_fam_properties_in_create_index_node1555);
		p=fam_properties();
		state._fsp--;
		if (state.failed) return ret;
	}
	break;
{code}

what I can't answer, is why we have this logic at all (though I didn't dive into the parser.

Maybe [~jamestaylor] can shed some light here?


was (Author: jesse_yates):
This seems more like a band-aid than the fix for the real issue (though it does fix it), which is why aren't the properties set correctly? They are going to be null unless we have fam_properties set, as from the grammar (ln 390-397):
{code}
create_index_node returns [CreateIndexStatement ret]
    :   CREATE l=LOCAL? INDEX (IF NOT ex=EXISTS)? i=index_name ON t=from_table_name
        (LPAREN pk=index_pk_constraint RPAREN)
        (INCLUDE (LPAREN icrefs=column_names RPAREN))?
        (p=fam_properties)?
        (SPLIT ON v=value_expression_list)?
        {ret = factory.createIndex(i, factory.namedTable(null,t), pk, icrefs, v, p, ex!=null, l==null ? IndexType.getDefault() : IndexType.LOCAL, getBindCount()); }
    ;
{code}

As generated in the PhoenixSQLParser (ln 1297-1305):
{code}
				case 1 :
					// PhoenixSQL.g:394:10: p= fam_properties
					{
					pushFollow(FOLLOW_fam_properties_in_create_index_node1555);
					p=fam_properties();
					state._fsp--;
					if (state.failed) return ret;
					}
					break;
{code}

what I can't answer, is why we have this logic at all (though I didn't dive into the parser.

Maybe [~jamestaylor] can shed some light here?

> create index throws NPE when dataTable has specified default column family
> --------------------------------------------------------------------------
>
>                 Key: PHOENIX-1305
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1305
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: daniel meng
>         Attachments: PHOENIX-1305.patch
>
>
> {code:sql}
> create table S.T (k varchar not null primary key, v1 varchar, v2 varchar) DEFAULT_COLUMN_FAMILY='A'
> create index I on S.T (v1) include (v2)
> {code}
> {code}
> java.lang.NullPointerException
>    at org.apache.phoenix.schema.MetaDataClient.createIndex(MetaDataClient.java:704)
>    at org.apache.phoenix.compile.CreateIndexCompiler$1.execute(CreateIndexCompiler.java:76)
>    at org.apache.phoenix.jdbc.PhoenixStatement$3.call(PhoenixStatement.java:252)
>    at org.apache.phoenix.jdbc.PhoenixStatement$3.call(PhoenixStatement.java:1)
>    at org.apache.phoenix.util.PhoenixContextExecutor.call(PhoenixContextExecutor.java:54)
>    at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:242)
>    at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:966)
>    at org.apache.phoenix.end2end.index.CreateIndexIT.testWriteFailureDropIndex(CreateIndexIT.java:131)
>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>    at java.lang.reflect.Method.invoke(Method.java:597)
>    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
>    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
>    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>    at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)
> {code}



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