apachephoenix create语句作为select(from)

but5z9lq  于 2021-06-10  发布在  Hbase
关注(0)|答案(1)|浏览(518)

我正在尝试从phoenix中的现有结构创建一个新表。在phoenix中是否有create as select语句。我正在努力,但他们失败了,只有以下例外。
欢迎提出任何建议。提前谢谢。

  1. CREATE TABLE TEST AS (SELECT * FROM TEST_2 WHERE 1 =2);
  2. org.apache.phoenix.exception.PhoenixParserException: ERROR 601 (42P00): Syntax error. Encountered "AS" at line 1, column 14.
  3. at org.apache.phoenix.exception.PhoenixParserException.newException(PhoenixParserException.java:33)
  4. at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:111)
  5. at org.apache.phoenix.jdbc.PhoenixStatement$PhoenixStatementParser.parseStatement(PhoenixStatement.java:1280)
  6. at org.apache.phoenix.jdbc.PhoenixStatement.parseStatement(PhoenixStatement.java:1363)
  7. at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1434)
  8. at sqlline.Commands.execute(Commands.java:822)
  9. at sqlline.Commands.sql(Commands.java:732)
  10. at sqlline.SqlLine.dispatch(SqlLine.java:808)
  11. at sqlline.SqlLine.begin(SqlLine.java:681)
  12. at sqlline.SqlLine.start(SqlLine.java:398)
  13. at sqlline.SqlLine.main(SqlLine.java:292)
  14. Caused by: NoViableAltException(11@[])
  15. at org.apache.phoenix.parse.PhoenixSQLParser.from_table_name(PhoenixSQLParser.java:9564)
  16. at org.apache.phoenix.parse.PhoenixSQLParser.create_table_node(PhoenixSQLParser.java:1096)
  17. at org.apache.phoenix.parse.PhoenixSQLParser.oneStatement(PhoenixSQLParser.java:816)
  18. at org.apache.phoenix.parse.PhoenixSQLParser.statement(PhoenixSQLParser.java:508)
  19. at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:108)
  20. ... 9 more
  21. CREATE TEST (SELECT * FROM TEST_2 WHERE 1=2);
  22. org.apache.phoenix.exception.PhoenixParserException: ERROR 601 (42P00): Syntax error. Encountered "SELECT" at line 1, column 34.
  23. at org.apache.phoenix.exception.PhoenixParserException.newException(PhoenixParserException.java:33)
  24. at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:111)
  25. at org.apache.phoenix.jdbc.PhoenixStatement$PhoenixStatementParser.parseStatement(PhoenixStatement.java:1280)
  26. at org.apache.phoenix.jdbc.PhoenixStatement.parseStatement(PhoenixStatement.java:1363)
  27. at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1434)
  28. at sqlline.Commands.execute(Commands.java:822)
  29. at sqlline.Commands.sql(Commands.java:732)
  30. at sqlline.SqlLine.dispatch(SqlLine.java:808)
  31. at sqlline.SqlLine.begin(SqlLine.java:681)
  32. at sqlline.SqlLine.start(SqlLine.java:398)
  33. at sqlline.SqlLine.main(SqlLine.java:292)
  34. Caused by: NoViableAltException(133@[])
  35. at org.apache.phoenix.parse.PhoenixSQLParser.column_name(PhoenixSQLParser.java:2553)
  36. at org.apache.phoenix.parse.PhoenixSQLParser.column_def(PhoenixSQLParser.java:3934)
  37. at org.apache.phoenix.parse.PhoenixSQLParser.column_defs(PhoenixSQLParser.java:3858)
  38. at org.apache.phoenix.parse.PhoenixSQLParser.create_table_node(PhoenixSQLParser.java:1104)
  39. at org.apache.phoenix.parse.PhoenixSQLParser.oneStatement(PhoenixSQLParser.java:816)
  40. at org.apache.phoenix.parse.PhoenixSQLParser.statement(PhoenixSQLParser.java:508)
  41. at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:108)
e3bfsja2

e3bfsja21#

你不能在家里这样做 Phoenix .
相反,您需要先创建一个现有hbase/phoenix表的视图,在您的示例中,该视图是' test_2 '
所以你可以这样做:

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

更多信息请参考:Phoenix城

相关问题