phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jody Landreneau <jodylandren...@gmail.com>
Subject null array
Date Sat, 17 May 2014 04:16:28 GMT
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
*setNull
<http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#setNull(int,%20int)>*(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 --

Mime
View raw message