I am beginner with Phoenix, HBase and Python and am writing a small POC using Pyspark to retrieve some basic information from HBase DB using Phoenix.
Here is my code snippet.
query = 'select count(PK) from A_Model.TableA'
jdbc_url = 'jdbc:phoenix:..xxx/hbase-secure'
df_records = sparkConfig.getSqlContext().read.format('jdbc')\
.options(driver='org.apache.phoenix.jdbc.PhoenixDriver', url=jdbc_url, dbtable=query).load()
When trying to run this using spark-submit, i get the following error
`
Traceback (most recent call last):
File "/users/s190641/Tejas_Test/ahi_rpt_test.py", line 54, in <module>
main()
...
...
.options(driver='org.apache.phoenix.jdbc.PhoenixDriver', url=jdbc_url, dbtable=query).load()
File "/usr/hdp/current/spark-client/python/lib/pyspark.zip/pyspark/sql/readwriter.py", line 139, in load
File "/usr/hdp/current/spark-client/python/lib/py4j-0.9-src.zip/py4j/java_gateway.py", line 813, in __call__
File "/usr/hdp/current/spark-client/python/lib/pyspark.zip/pyspark/sql/utils.py", line 45, in deco
File "/usr/hdp/current/spark-client/python/lib/py4j-0.9-src.zip/py4j/protocol.py", line 308, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o62.load.
: org.apache.phoenix.exception.PhoenixParserException: ERROR 601 (42P00): Syntax error. Encountered "select" at line 1, column 15.
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.PhoenixPreparedStatement.<init>(PhoenixPreparedStatement.java:94)
at org.apache.phoenix.jdbc.PhoenixConnection.prepareStatement(PhoenixConnection.java:723)
at org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:122)
at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation.<init>(JDBCRelation.scala:91)
at org.apache.spark.sql.execution.datasources.jdbc.DefaultSource.createRelation(DefaultSource.scala:57)
at org.apache.spark.sql.execution.datasources.ResolvedDataSource$.apply(ResolvedDataSource.scala:158)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:119)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:381)
at py4j.Gateway.invoke(Gateway.java:259)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:209)
at java.lang.Thread.run(Thread.java:745)
Caused by: NoViableAltException(133@[])
at org.apache.phoenix.parse.PhoenixSQLParser.table_factor(PhoenixSQLParser.java:6195)
at org.apache.phoenix.parse.PhoenixSQLParser.table_ref(PhoenixSQLParser.java:6083)
at org.apache.phoenix.parse.PhoenixSQLParser.table_list(PhoenixSQLParser.java:6019)
at org.apache.phoenix.parse.PhoenixSQLParser.parseFrom(PhoenixSQLParser.java:5984)
at org.apache.phoenix.parse.PhoenixSQLParser.single_select(PhoenixSQLParser.java:4612)
at org.apache.phoenix.parse.PhoenixSQLParser.unioned_selects(PhoenixSQLParser.java:4714)
at org.apache.phoenix.parse.PhoenixSQLParser.select_node(PhoenixSQLParser.java:4780)
at org.apache.phoenix.parse.PhoenixSQLParser.oneStatement(PhoenixSQLParser.java:789)
at org.apache.phoenix.parse.PhoenixSQLParser.statement(PhoenixSQLParser.java:508)
at org.apache.phoenix.parse.SQLParser.parseStatement(SQLParser.java:108)
... 20 more
`