Apache Phoenix Create语句为select(从) [英] Apache Phoenix Create statement as select (from)

查看:358
本文介绍了Apache Phoenix Create语句为select(从)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Phoenix中的现有结构创建一个新表.在Phoenix中是否有一个CREATE as Select语句.我正在尝试,但失败了,但出现以下异常.

I am trying to create a new table from an existing structure in Phoenix. Is there a CREATE as Select statement in Phoenix. I am trying and they are failing with the below exception.

欢迎在这里提出任何建议.预先感谢.

Any suggestions here are welcome. Thanks in advance.

 CREATE TABLE TEST AS (SELECT * FROM TEST_2 WHERE 1 =2);

org.apache.phoenix.exception.PhoenixParserException: ERROR 601 (42P00): Syntax error. Encountered "AS" at line 1, column 14.
        at org.apache.phoenix.exception.PhoenixParserException.newException(PhoenixParserException.java:33)
        at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:111)
        at org.apache.phoenix.jdbc.PhoenixStatement$PhoenixStatementParser.parseStatement(PhoenixStatement.java:1280)
        at org.apache.phoenix.jdbc.PhoenixStatement.parseStatement(PhoenixStatement.java:1363)
        at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1434)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)
Caused by: NoViableAltException(11@[])
        at org.apache.phoenix.parse.PhoenixSQLParser.from_table_name(PhoenixSQLParser.java:9564)
        at org.apache.phoenix.parse.PhoenixSQLParser.create_table_node(PhoenixSQLParser.java:1096)
        at org.apache.phoenix.parse.PhoenixSQLParser.oneStatement(PhoenixSQLParser.java:816)
        at org.apache.phoenix.parse.PhoenixSQLParser.statement(PhoenixSQLParser.java:508)
        at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:108)
        ... 9 more
CREATE TEST  (SELECT * FROM TEST_2 WHERE 1=2);
org.apache.phoenix.exception.PhoenixParserException: ERROR 601 (42P00): Syntax error. Encountered "SELECT" at line 1, column 34.
        at org.apache.phoenix.exception.PhoenixParserException.newException(PhoenixParserException.java:33)
        at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:111)
        at org.apache.phoenix.jdbc.PhoenixStatement$PhoenixStatementParser.parseStatement(PhoenixStatement.java:1280)
        at org.apache.phoenix.jdbc.PhoenixStatement.parseStatement(PhoenixStatement.java:1363)
        at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1434)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)
Caused by: NoViableAltException(133@[])
        at org.apache.phoenix.parse.PhoenixSQLParser.column_name(PhoenixSQLParser.java:2553)
        at org.apache.phoenix.parse.PhoenixSQLParser.column_def(PhoenixSQLParser.java:3934)
        at org.apache.phoenix.parse.PhoenixSQLParser.column_defs(PhoenixSQLParser.java:3858)
        at org.apache.phoenix.parse.PhoenixSQLParser.create_table_node(PhoenixSQLParser.java:1104)
        at org.apache.phoenix.parse.PhoenixSQLParser.oneStatement(PhoenixSQLParser.java:816)
        at org.apache.phoenix.parse.PhoenixSQLParser.statement(PhoenixSQLParser.java:508)
        at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:108)

推荐答案

不能Phoenix中这样做.

相反,您首先需要为现有的 Hbase/Phoenix 表创建一个视图,在您的情况下为"test_2"

Instead you need to create a view of a existing Hbase/Phoenix table first which in your case is 'test_2'

因此您可以执行以下操作:

So you can do something like this:

CREATE VIEW test_view (a VARCHAR, b VARCHAR) AS
SELECT * FROM test_2
WHERE 1 = 2 ;  // some condition

有关更多信息,请参见:凤凰

For more information refer here : Phoenix

这篇关于Apache Phoenix Create语句为select(从)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆