5

I have create the following table:

CREATE TABLE IF NOT EXISTS "events" (
"product.name" VARCHAR(32),
"event.name" VARCHAR(32),
"event.uuid" VARCHAR(32),
CONSTRAINT pk PRIMARY KEY ("event.uuid")
)

Inserting an event:

upsert into "events" ("event.uuid", "event.name", "product.name") values('1', 'click', 'api')

Getting data from HBase shell:

hbase(main):020:0> scan 'events'
ROW                                                  COLUMN+CELL
 1                                                   column=0:_0, timestamp=1449417795078, value=
 1                                                   column=0:event.name, timestamp=1449417795078, value=click
 1                                                   column=0:product.name, timestamp=1449417795078, value=api
1 row(s) in 0.0200 seconds

No column familty ;-(

From HBase shell, trying to insert data:

hbase(main):021:0> put 'events', '2', 'event:name','buy'

ERROR: Unknown column family! Valid column names: 0:*

Why?

Thomas Decaux
  • 21,738
  • 2
  • 113
  • 124

1 Answers1

10

A double quoted identifier makes it case sensitive, so if you want both the column family and the column name to be case sensitive, you'll need to surround them each separately in double quotes like this:

CREATE TABLE IF NOT EXISTS "events" (
    "product"."name" VARCHAR(32),
    "event"."name" VARCHAR(32),
    "event"."uuid" VARCHAR(32),
    CONSTRAINT pk PRIMARY KEY ("event"."uuid")
)

and then upsert like this:

UPSERT INTO "events" ("event"."uuid", "event"."name", "product"."name")
    VALUES ('1', 'click', 'api')

Qualifying the column name with the column family name is not required in the UPSERT statement unless the column name is ambiguous. If you don't need to match the format of existing data, another alternative is to just not double quote anything. Otherwise, for an example, see this FAQ.

FWIW, best place to ask question is on our dev or user mailing lists.

James Taylor
  • 206
  • 2
  • 3
  • D'oh! I have read only https://phoenix.apache.org/language/index.html#column_ref . Thanks you very much. – Thomas Decaux Dec 07 '15 at 08:35
  • This ain't working for me and throwing this error: Error: ERROR 1003 (42J01): Primary key columns must not have a family name. columnName=event.uuid – Saahil Gupta Apr 27 '18 at 04:55
  • The columns that make up your primary key shouldn't not be prefixed with a column family (just like the message says). This will work fine: CREATE TABLE IF NOT EXISTS "events" ( "product"."name" VARCHAR(32), "event"."name" VARCHAR(32), "uuid" VARCHAR(32), CONSTRAINT pk PRIMARY KEY ("uuid") ) – James Taylor Apr 28 '18 at 05:36