2

I know Apache Phoenix will store all function metadata in SYSTEM.FUNCTION, but when I perform the query use following statement it will throw exception.

0: jdbc:phoenix:10.1.226.15:2181> select * from SYSTEM.FUNCTION;
Error: ERROR 604 (42P00): Syntax error. Mismatched input. Expecting "NAME", got "FUNCTION" at line 1, column 22. (state=42P00,code=604)
org.apache.phoenix.exception.PhoenixParserException: ERROR 604 (42P00): Syntax error. Mismatched input. Expecting "NAME", got "FUNCTION" at line 1, column 22.
    at org.apache.phoenix.exception.PhoenixParserException.newException(PhoenixParserException.java:33)

or

0: jdbc:phoenix:10.1.226.15:2181> select * from FUNCTION;
Error: ERROR 601 (42P00): Syntax error. Encountered "FUNCTION" at line 1, column 15. (state=42P00,code=601)
org.apache.phoenix.exception.PhoenixParserException: ERROR 601 (42P00): Syntax error. Encountered "FUNCTION" at line 1, column 15.

The table FUNCTION exist in SYSTEM schema, but can not query, in other hand, the table CATALOG in SYSTEM schema I can perform statement and retrieves the right data.

0: jdbc:phoenix:10.1.226.15:2181> !tables
+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------+
|                TABLE_CAT                 |               TABLE_SCHEM                |                TABLE_NAME                |                TABLE_TYPE                |                 REMARKS            |
+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------+
|                                          | SYSTEM                                   | CATALOG                                  | SYSTEM TABLE                             |                                    |
|                                          | SYSTEM                                   | FUNCTION                                 | SYSTEM TABLE                             |                                    |
|                                          | SYSTEM                                   | SEQUENCE                                 | SYSTEM TABLE                             |                                    |
|                                          | SYSTEM                                   | STATS                                    | SYSTEM TABLE                             |                                    |
+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------+



0: jdbc:phoenix:10.1.226.15:2181> select * from system.catalog;
+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------+
|                TENANT_ID                 |               TABLE_SCHEM                |                TABLE_NAME                |               COLUMN_NAME                |              COLUMN_FAMILY         |
+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------------+------------------------------------+
|                                          | SYSTEM                                   | CATALOG                                  |                                          |                                    |
|                                          | SYSTEM                                   | CATALOG                                  | ARRAY_SIZE                               | 0                                  |
|                                          | SYSTEM                                   | CATALOG                                  | BUFFER_LENGTH                            | 0                                  |
....

Can somebody explain why?

4

1 回答 1

2

function, like select, 是保留关键字。如果您想引用该表,请将其括在引号中(并且它也将区分大小写)。

于 2016-08-09T04:33:22.300 回答