That worked ; Thank you, Samarth !

Naga

On Mar 11, 2015, at 2:19 PM, Samarth Jain 
<[email protected]<mailto:[email protected]>> wrote:

Hi Naga,

Can you try

create table mt3 (
  tenant_id   varchar NOT NULL,
  tenant_name varchar
  constraint mt_pk primary key (tenant_id, tenant_name)
) multi_tenant=true;

- Samarth


On Wednesday, March 11, 2015, Naga Vijayapuram 
<[email protected]<mailto:[email protected]>> wrote:
I am on HDP 2.2 ; it uses Phoenix 4.2 ; Is this fixed in Phoenix 4.3 by any 
chance?

Thanks
Naga

On Mar 11, 2015, at 2:03 PM, Naga Vijayapuram 
<[email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>>
 wrote:

Hi,

I seem to have hit upon some issue with Multitenancy.

Showing the issue with three different file syntaxes below.

Any idea what I am missing?

Thanks
Naga

> for f in mt?.sql; do cat $f; psql $f; done

create table mt1 (
  tenant_id varchar primary key
) multi_tenant=true;

15/03/11 16:58:42 WARN impl.MetricsConfig: Cannot locate configuration: tried 
hadoop-metrics2-phoenix.properties,hadoop-metrics2.properties
java.sql.SQLException: ERROR 1040 (42Y96): A MULTI_TENANT table must have two 
or more PK columns with the first column being NOT NULL and of type VARCHAR or 
CHAR. tableName=MT1
at 
org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:336)
at 
org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:133)
at 
org.apache.phoenix.schema.MetaDataClient.throwIfInsufficientColumns(MetaDataClient.java:1613)
at 
org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:1379)
at org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:535)
at 
org.apache.phoenix.compile.CreateTableCompiler$2.execute(CreateTableCompiler.java:184)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:260)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:252)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at 
org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:250)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:196)
at 
org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:172)
at 
org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:177)
at 
org.apache.phoenix.jdbc.PhoenixConnection.executeStatements(PhoenixConnection.java:262)
at 
org.apache.phoenix.util.PhoenixRuntime.executeStatements(PhoenixRuntime.java:241)
at org.apache.phoenix.util.PhoenixRuntime.main(PhoenixRuntime.java:187)

create table mt2 (
  tenant_id      varchar primary key,
  tenant_name    varchar primary key
) multi_tenant=true;

15/03/11 16:58:45 WARN impl.MetricsConfig: Cannot locate configuration: tried 
hadoop-metrics2-phoenix.properties,hadoop-metrics2.properties
java.sql.SQLException: ERROR 510 (42889): The table already has a primary key. 
columnName=TENANT_NAME
at 
org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:336)
at 
org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:133)
at 
org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:1281)
at org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:535)
at 
org.apache.phoenix.compile.CreateTableCompiler$2.execute(CreateTableCompiler.java:184)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:260)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:252)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at 
org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:250)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:196)
at 
org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:172)
at 
org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:177)
at 
org.apache.phoenix.jdbc.PhoenixConnection.executeStatements(PhoenixConnection.java:262)
at 
org.apache.phoenix.util.PhoenixRuntime.executeStatements(PhoenixRuntime.java:241)
at org.apache.phoenix.util.PhoenixRuntime.main(PhoenixRuntime.java:187)

create table mt3 (
  tenant_id   varchar,
  tenant_name varchar
  constraint mt_pk primary key (tenant_id, tenant_name)
) multi_tenant=true;

15/03/11 16:58:48 WARN impl.MetricsConfig: Cannot locate configuration: tried 
hadoop-metrics2-phoenix.properties,hadoop-metrics2.properties
java.sql.SQLException: ERROR 1040 (42Y96): A MULTI_TENANT table must have two 
or more PK columns with the first column being NOT NULL and of type VARCHAR or 
CHAR. tableName=MT3
at 
org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:336)
at 
org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:133)
at 
org.apache.phoenix.schema.MetaDataClient.throwIfInsufficientColumns(MetaDataClient.java:1624)
at 
org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:1379)
at org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:535)
at 
org.apache.phoenix.compile.CreateTableCompiler$2.execute(CreateTableCompiler.java:184)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:260)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:252)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at 
org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:250)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:196)
at 
org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:172)
at 
org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:177)
at 
org.apache.phoenix.jdbc.PhoenixConnection.executeStatements(PhoenixConnection.java:262)
at 
org.apache.phoenix.util.PhoenixRuntime.executeStatements(PhoenixRuntime.java:241)
at org.apache.phoenix.util.PhoenixRuntime.main(PhoenixRuntime.java:187)


Reply via email to