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?

Jeffy Zhang
  • 101
  • 1
  • 8

1 Answers1

2

function, like select, is a reserved keyword. If you would like to refer to the table, enclose it in quotations (and it will also become case-sensitive).

kliew
  • 2,687
  • 1
  • 11
  • 25