You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by chengboqun <ch...@ict.ac.cn> on 2014/05/20 07:07:46 UTC

unsubscribe

 

 

发件人: user-return-679-chengboqun=ict.ac.cn@phoenix.incubator.apache.org [mailto:user-return-679-chengboqun=ict.ac.cn@phoenix.incubator.apache.org] 代表 Jody Landreneau
发送时间: 2014年5月20日 2:01
收件人: user@phoenix.incubator.apache.org
主题: Re: null array

 

Thank you James! 

We appreciate your work on this. I've created https://issues.apache.org/jira/browse/PHOENIX-989 to track the issue.

 

On Fri, May 16, 2014 at 11:17 PM, James Taylor <ja...@apache.org> wrote:

Hi Jody,

Those are definitely bugs - you should be able to set a column of type ARRAY to null. Please file a JIRA and we'll get this fixed up. Sorry for the inconvenience.

Thanks,

James

 

On Fri, May 16, 2014 at 9:16 PM, Jody Landreneau <jo...@gmail.com> wrote:

Hello all,

 

I am using phoenix arrays. My question is in regards as to how you would set null for an empty array or for the array field type. I can't seem to get that to work. If I have a string[] I can set an array with a single empty string, but it seems like I should be able to set the param to null. I don't know what I would do for another type of array like bigint.  

 

Example:

CREATE TABLE regions (

region_name VARCHAR NOT NULL,

nullable_field VARCHAR,

zips VARCHAR[]

CONSTRAINT pk PRIMARY KEY (region_name));

 

I can

 

UPSERT INTO regions(region_name, nullable_field)

VALUES('SF Bay Area', null)

 

but not

 

UPSERT INTO regions(region_name, nullable_field, zips)

VALUES('SF Bay Area', 'one', null)

 

I can also

UPSERT INTO regions(region_name, nullable_field, zips)

VALUES('SF Bay Area', null, ARRAY[''])

and this seems to return null for the array but not sure how to use this approach for other types.

 

I have the same issue attempting to use jdbc, when I call the PreparedStatement's

 <http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#setNull(int,%20int)> setNull(int parameterIndex, int sqlType) and I set the sqlType to ARRAY.

 

Seems that the error I get is

java.lang.NullPointerException

at org.apache.phoenix.schema.PDataType$27.isCoercibleTo(PDataType.java:3455)

at org.apache.phoenix.compile.UpsertCompiler$3.execute(UpsertCompiler.java:695)

at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:226)

at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:185)

at org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:146)

at org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:151)

Any thoughts on what I should be seeing or doing?

 

Thanks in advance --