2016-12-21 4 views
1

phonix의 기존 구조에서 새 테이블을 만들려고합니다. Phoenix에서 Select 문으로 CREATE가 있습니까? 나는 노력하고있다. 그리고 그들은 아래 예외와 함께 실패하고있다.Apache Phoenix select from (from)

모든 제안은 환영합니다. 미리 감사드립니다.

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([email protected][]) 
     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([email protected][]) 
     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) 

답변

1

당신 Phoenix에서 다음과 같이하지 수 있습니다.

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

:

대신 당신은 당신의 경우 'test_2은'

그래서 당신은 이런 식으로 뭔가를 할 수있는 처음 기존 HBase를/피닉스 테이블의 보기를 작성해야 자세한 내용은 여기를 참조하십시오 : Phoenix