我知道Apache Phoenix会在SYSTEM.FUNCTION中存储所有函数元数据,但是当我执行查询时使用以下语句会抛出异常。
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)
或
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.
表FUNCTION存在于SYSTEM模式中,但是不能查询,另一方面,SYSTEM模式中的表CATALOG我可以执行语句并检索正确的数据。
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 |
....
有人可以解释原因吗?
答案 0 :(得分:2)
function
与select
一样,是保留关键字。如果您想参考该表,请将其括在引号中(它也将区分大小写)。