You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by xin geng <dr...@icloud.com> on 2018/11/15 05:38:50 UTC

Probably issue of DEFAULT column value when creating table

Hi, all

I'm learning phoenix, when trying to create table with the sql below, I met a ColumnNotFoundException, which probably be a issue of phoenix. Please correct me if I'm wrong. :)

SQL:
CREATE TABLE TEST (
a BIGINT NOT NULL DEFAULT 0,
b CHAR(10) DEFAULT "abc",
cf.c INTEGER DEFAULT 1
CONSTRAINT pk PRIMARY KEY (a ASC, b ASC)
);

Exeption:
Error: ERROR 504 (42703): Undefined column. columnName=abc (state=42703,code=504)
org.apache.phoenix.schema.ColumnNotFoundException: ERROR 504 (42703): Undefined column. columnName=abc
at org.apache.phoenix.compile.FromCompiler$1.resolveColumn(FromCompiler.java:129)
at org.apache.phoenix.compile.ExpressionCompiler.resolveColumn(ExpressionCompiler.java:372)
at org.apache.phoenix.compile.ExpressionCompiler.visit(ExpressionCompiler.java:408)
at org.apache.phoenix.compile.ExpressionCompiler.visit(ExpressionCompiler.java:146)
at org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56)
at org.apache.phoenix.parse.ColumnDef.validateDefault(ColumnDef.java:246)
at org.apache.phoenix.compile.CreateTableCompiler.compile(CreateTableCompiler.java:108)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableCreateTableStatement.compilePlan(PhoenixStatement.java:788)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableCreateTableStatement.compilePlan(PhoenixStatement.java:777)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:387)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:377)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:375)
at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:364)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1738)
at sqlline.Commands.execute(Commands.java:822)
at sqlline.Commands.sql(Commands.java:732)
at sqlline.SqlLine.dispatch(SqlLine.java:813)
at sqlline.SqlLine.begin(SqlLine.java:686)
at sqlline.SqlLine.start(SqlLine.java:398)
at sqlline.SqlLine.main(SqlLine.java:291)

I'm using phoenix4.13.1 and hbase1.2.5.

Re: Probably issue of DEFAULT column value when creating table

Posted by gengxin <dr...@icloud.com>.
Hi Francis,

It worked, thanks!

> 在 2018年11月15日,13:59,Francis Chuang <fr...@apache.org> 写道:
> 
> Can you try enclosing the string with single quotes (haven't tried this myself as I currently don't have access to my Phoenix test cluster):
> 
> CREATE TABLE TEST (
> a BIGINT NOT NULL DEFAULT 0,
> b CHAR(10) DEFAULT 'abc',
> cf.c INTEGER DEFAULT 1
> CONSTRAINT pk PRIMARY KEY (a ASC, b ASC)
> );
> 
> On 15/11/2018 4:38 pm, xin geng wrote:
>> Hi, all
>> 
>> I'm learning phoenix, when trying to create table with the sql below, I met a ColumnNotFoundException, which probably be a issue of phoenix. Please correct me if I'm wrong. :)
>> 
>> SQL:
>> CREATE TABLE TEST (
>> a BIGINT NOT NULL DEFAULT 0,
>> b CHAR(10) DEFAULT "abc",
>> cf.c INTEGER DEFAULT 1
>> CONSTRAINT pk PRIMARY KEY (a ASC, b ASC)
>> );
>> 
>> Exeption:
>> Error: ERROR 504 (42703): Undefined column. columnName=abc (state=42703,code=504)
>> org.apache.phoenix.schema.ColumnNotFoundException: ERROR 504 (42703): Undefined column. columnName=abc
>> at org.apache.phoenix.compile.FromCompiler$1.resolveColumn(FromCompiler.java:129)
>> at org.apache.phoenix.compile.ExpressionCompiler.resolveColumn(ExpressionCompiler.java:372)
>> at org.apache.phoenix.compile.ExpressionCompiler.visit(ExpressionCompiler.java:408)
>> at org.apache.phoenix.compile.ExpressionCompiler.visit(ExpressionCompiler.java:146)
>> at org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56)
>> at org.apache.phoenix.parse.ColumnDef.validateDefault(ColumnDef.java:246)
>> at org.apache.phoenix.compile.CreateTableCompiler.compile(CreateTableCompiler.java:108)
>> at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableCreateTableStatement.compilePlan(PhoenixStatement.java:788)
>> at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableCreateTableStatement.compilePlan(PhoenixStatement.java:777)
>> at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:387)
>> at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:377)
>> at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
>> at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:375)
>> at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:364)
>> at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1738)
>> at sqlline.Commands.execute(Commands.java:822)
>> at sqlline.Commands.sql(Commands.java:732)
>> at sqlline.SqlLine.dispatch(SqlLine.java:813)
>> at sqlline.SqlLine.begin(SqlLine.java:686)
>> at sqlline.SqlLine.start(SqlLine.java:398)
>> at sqlline.SqlLine.main(SqlLine.java:291)
>> 
>> I'm using phoenix4.13.1 and hbase1.2.5.
> 
> 


Re: Probably issue of DEFAULT column value when creating table

Posted by Francis Chuang <fr...@apache.org>.
Can you try enclosing the string with single quotes (haven't tried this 
myself as I currently don't have access to my Phoenix test cluster):

CREATE TABLE TEST (
a BIGINT NOT NULL DEFAULT 0,
b CHAR(10) DEFAULT 'abc',
cf.c INTEGER DEFAULT 1
CONSTRAINT pk PRIMARY KEY (a ASC, b ASC)
);

On 15/11/2018 4:38 pm, xin geng wrote:
> Hi, all
>
> I'm learning phoenix, when trying to create table with the sql below, 
> I met a ColumnNotFoundException, which probably be a issue of phoenix. 
> Please correct me if I'm wrong. :)
>
> SQL:
> CREATE TABLE TEST (
> a BIGINT NOT NULL DEFAULT 0,
> b CHAR(10) DEFAULT "abc",
> cf.c INTEGER DEFAULT 1
> CONSTRAINT pk PRIMARY KEY (a ASC, b ASC)
> );
>
> Exeption:
> Error: ERROR 504 (42703): Undefined column. columnName=abc 
> (state=42703,code=504)
> org.apache.phoenix.schema.ColumnNotFoundException: ERROR 504 (42703): 
> Undefined column. columnName=abc
> at 
> org.apache.phoenix.compile.FromCompiler$1.resolveColumn(FromCompiler.java:129)
> at 
> org.apache.phoenix.compile.ExpressionCompiler.resolveColumn(ExpressionCompiler.java:372)
> at 
> org.apache.phoenix.compile.ExpressionCompiler.visit(ExpressionCompiler.java:408)
> at 
> org.apache.phoenix.compile.ExpressionCompiler.visit(ExpressionCompiler.java:146)
> at 
> org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56)
> at org.apache.phoenix.parse.ColumnDef.validateDefault(ColumnDef.java:246)
> at 
> org.apache.phoenix.compile.CreateTableCompiler.compile(CreateTableCompiler.java:108)
> at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableCreateTableStatement.compilePlan(PhoenixStatement.java:788)
> at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableCreateTableStatement.compilePlan(PhoenixStatement.java:777)
> at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:387)
> at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:377)
> at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
> at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:375)
> at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:364)
> at 
> org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1738)
> at sqlline.Commands.execute(Commands.java:822)
> at sqlline.Commands.sql(Commands.java:732)
> at sqlline.SqlLine.dispatch(SqlLine.java:813)
> at sqlline.SqlLine.begin(SqlLine.java:686)
> at sqlline.SqlLine.start(SqlLine.java:398)
> at sqlline.SqlLine.main(SqlLine.java:291)
>
> I'm using phoenix4.13.1 and hbase1.2.5.