<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Getting NullPointer Exception when a join query is executed on a Phoenix Database in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412062#M253229</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82089"&gt;@willx&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/93041"&gt;@ayushi&lt;/a&gt;&amp;nbsp;Hi! By any chance do you have some insights here? Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 08 Aug 2025 22:54:04 GMT</pubDate>
    <dc:creator>DianaTorres</dc:creator>
    <dc:date>2025-08-08T22:54:04Z</dc:date>
    <item>
      <title>Getting NullPointer Exception when a join query is executed on a Phoenix Database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412013#M253189</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;SPAN&gt;I'm attempting to run a simple join query between two tables in an Apache Phoenix database on a Spark cluster. However, when I try to read from the resulting DataFrame after executing the query, I encounter a NullPointerException.&lt;/SPAN&gt;&lt;BR /&gt;Query :&amp;nbsp;&lt;FONT size="2"&gt;&lt;STRONG&gt;&lt;EM&gt;(SELECT CONNTEST.EMPLOYEEFILTERJOIN.EMP_ID,CONNTEST.EMPLOYEEFILTERJOIN.NAME,CONNTEST.EMPLOYEEFILTERJOIN.SALARY,CONNTEST.DEPARTMENTFILTERJOIN.DEPT_ID,CONNTEST.DEPARTMENTFILTERJOIN.DETP_NAME FROM CONNTEST.EMPLOYEEFILTERJOIN,CONNTEST.DEPARTMENTFILTERJOIN WHERE CONNTEST.EMPLOYEEFILTERJOIN.EMP_ID=CONNTEST.DEPARTMENTFILTERJOIN.EMP_ID) query_alias&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;Below is the code I'm executing,&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="4"&gt;val spark = SparkSession.builder()&lt;BR /&gt;.appName("PhoenixWriteIssueSimulator")&lt;BR /&gt;.master("local[*]")&lt;BR /&gt;.config("spark.sql.catalogImplementation", "in-memory")&amp;nbsp;&lt;BR /&gt;.getOrCreate()&lt;BR /&gt;&lt;/FONT&gt;&lt;BR /&gt;val jdbcProperties = new Properties()&lt;BR /&gt;jdbcProperties.setProperty("driver","org.apache.phoenix.jdbc.PhoenixDriver")&lt;BR /&gt;&lt;BR /&gt;var df = spark.read&lt;BR /&gt;.jdbc(phoenixJdbcUrl, phoenixSourceQuery, jdbcProperties)&lt;BR /&gt;var df = spark.read&lt;BR /&gt;.jdbc(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; url = s"${phoenixJdbcUrl}",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; table = s"${phoenixSourceQuery}",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; properties = jdbcProperties&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;df.show(20);&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;df.show(20)&lt;/STRONG&gt; is failing with the below stacktrace,&lt;/P&gt;&lt;PRE&gt;25/08/01 15:34:51 ERROR executor.Executor: Exception in task 0.0 in stage 0.0 (TID 0)
java.lang.NullPointerException
	at org.apache.phoenix.util.SchemaUtil.getSchemaNameFromFullName(SchemaUtil.java:713)
	at org.apache.phoenix.schema.TableNotFoundException.&amp;lt;init&amp;gt;(TableNotFoundException.java:44)
	at org.apache.phoenix.compile.FromCompiler$MultiTableColumnResolver.resolveTable(FromCompiler.java:1013)
	at org.apache.phoenix.compile.JoinCompiler$ColumnRefParseNodeVisitor.visit(JoinCompiler.java:1399)
	at org.apache.phoenix.compile.JoinCompiler$ColumnRefParseNodeVisitor.visit(JoinCompiler.java:1371)
	at org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56)
	at org.apache.phoenix.util.ParseNodeUtil.applyParseNodeVisitor(ParseNodeUtil.java:67)
	at org.apache.phoenix.compile.JoinCompiler.compile(JoinCompiler.java:172)
	at org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:248)
	at org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:178)
	at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:543)
	at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:506)
	at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:311)
	at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:300)
	at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
	at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:299)
	at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:292)
	at org.apache.phoenix.jdbc.PhoenixPreparedStatement.executeQuery(PhoenixPreparedStatement.java:190)
	at org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD.compute(JDBCRDD.scala:304)
	at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:346)
	at org.apache.spark.rdd.RDD.iterator(RDD.scala:310)
	at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
	at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:346)
	at org.apache.spark.rdd.RDD.iterator(RDD.scala:310)
	at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
	at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:346)
	at org.apache.spark.rdd.RDD.iterator(RDD.scala:310)
	at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
	at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:346)
	at org.apache.spark.rdd.RDD.iterator(RDD.scala:310)
	at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
	at org.apache.spark.scheduler.Task.run(Task.scala:123)
	at org.apache.spark.executor.Executor$TaskRunner$$anonfun$14.apply(Executor.scala:459)
	at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1334)
	at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:465)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:750)&lt;/PRE&gt;&lt;P&gt;I have also checked the schame by printing df.printSchema() below is the output for the same,&lt;/P&gt;&lt;PRE&gt;root
 |-- CONNTEST.EMPLOYEEFILTERJOIN.EMP_ID: integer (nullable = true)
 |-- CONNTEST.EMPLOYEEFILTERJOIN.NAME: string (nullable = true)
 |-- CONNTEST.EMPLOYEEFILTERJOIN.SALARY: integer (nullable = true)
 |-- CONNTEST.DEPARTMENTFILTERJOIN.DEPT_ID: integer (nullable = true)
 |-- CONNTEST.DEPARTMENTFILTERJOIN.DETP_NAME: string (nullable = true)&lt;/PRE&gt;&lt;DIV class="py-3"&gt;After examining the Phoenix-Client-Hbase*.jar(phoenix-client-hbase-2.2-5.1.1.7.1.7.0-551.jar), which is the official Phoenix JDBC driver, I found that when executing a query containing a join condition, the driver calls the &lt;STRONG&gt;JoinCompiler.compile&lt;/STRONG&gt; method. In this method, I noticed that the Select statement uses select columns enclosed in double quotes.&lt;BR /&gt;However, when the &lt;STRONG&gt;JoinCompiler$ColumnRefParseNodeVisitor.visit&lt;/STRONG&gt; method processes these column nodes, both their table name and schema name are null.&lt;/DIV&gt;&lt;DIV class="py-3"&gt;For example, the column name appears as &lt;STRONG&gt;""CONNTEST.EMPLOYEEFILTERJOIN.EMP_ID""&lt;/STRONG&gt; (with two double quotes at the start and end). This causes a NullPointerException for these columns.&lt;/DIV&gt;&lt;DIV class="py-3"&gt;I suspected that the issue might be due to using fully qualified column names (schema.table.column) in the query, so I tried running this query:&lt;/DIV&gt;&lt;DIV class="py-3"&gt;&lt;STRONG&gt;(SELECT emp.EMP_ID, emp.NAME, emp.SALARY, dep.DEPT_ID, dep.DETP_NAME FROM CONNTEST.EMPLOYEEFILTERJOIN emp, CONNTEST.DEPARTMENTFILTERJOIN dep WHERE emp.EMP_ID = dep.EMP_ID) query_alias&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="py-3"&gt;However, the problem persists even with this query.&lt;/DIV&gt;&lt;DIV class="py-3"&gt;Could someone help me identify the root cause of this issue and clarify whether it might be a bug in the Phoenix JDBC driver?&lt;/DIV&gt;</description>
      <pubDate>Fri, 01 Aug 2025 10:44:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412013#M253189</guid>
      <dc:creator>Arun_Tejasvi</dc:creator>
      <dc:date>2025-08-01T10:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting NullPointer Exception when a join query is executed on a Phoenix Database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412031#M253203</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/129729"&gt;@Arun_Tejasvi&lt;/a&gt;,&amp;nbsp;Welcome to our community! To help you get the best possible answer, I have tagged in our Spark&amp;nbsp;experts&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/86141"&gt;@haridjh&lt;/a&gt;, who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Aug 2025 05:15:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412031#M253203</guid>
      <dc:creator>VidyaSargur</dc:creator>
      <dc:date>2025-08-05T05:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: Getting NullPointer Exception when a join query is executed on a Phoenix Database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412053#M253221</link>
      <description>&lt;P&gt;Hi Arun,&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Has this worked with earlier versions of Cloudera? Which version are you using in this case?&lt;/LI&gt;&lt;LI&gt;Phoenix supports views that can encapsulate joins. This avoids complex parsing issues with subqueries. Have we tried this approach?&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="java"&gt;CREATE VIEW CONNTEST.JOIN_VIEW AS
SELECT 
  emp.EMP_ID, 
  emp.NAME, 
  emp.SALARY, 
  dep.DEPT_ID, 
  dep.DETP_NAME
FROM CONNTEST.EMPLOYEEFILTERJOIN emp
JOIN CONNTEST.DEPARTMENTFILTERJOIN dep
ON emp.EMP_ID = dep.EMP_ID;

val df = spark.read
  .jdbc(
    url = phoenixJdbcUrl,
    table = "CONNTEST.JOIN_VIEW",
    properties = jdbcProperties
  )
df.show()&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;Is loading the two tables separately and joining them in Spark a viable option for you?&lt;/LI&gt;&lt;LI&gt;Spark also assigns an alias to the subquery clause -&amp;nbsp;&lt;A href="https://spark.apache.org/docs/3.5.1/sql-data-sources-jdbc.html" target="_blank"&gt;https://spark.apache.org/docs/3.5.1/sql-data-sources-jdbc.html&lt;/A&gt;. I am not sure the original approach will work as intended, but if you’re able to share examples where it has worked, we would be happy to take a closer look.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Hope these are good pointers for you to investigate further.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Aug 2025 22:05:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412053#M253221</guid>
      <dc:creator>Anshul_Gupta</dc:creator>
      <dc:date>2025-08-06T22:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Getting NullPointer Exception when a join query is executed on a Phoenix Database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412055#M253223</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/95577"&gt;@Anshul_Gupta&lt;/a&gt;,&lt;BR /&gt;Please find the answers below,&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;This is the first time we are testing this use case. Currently, we are using CDP version 7.1 with spark 3.3.2.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Phoenix only supports creating views over a single table using simple &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;SELECT *&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt; queries. Complex queries, including those with joins, are not supported. This limitation is documented in the Phoenix documentation under the limitations section&lt;/SPAN&gt;&amp;nbsp;-&amp;nbsp;&lt;A href="https://phoenix.apache.org/views.html" target="_blank" rel="noopener"&gt;https://phoenix.apache.org/views.html&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Loading the two tables separately and performing the join in Spark could lead to performance issues, especially if the datasets are large.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;As I mentioned earlier, this is the first time we're testing this approach. The issue only occurs when the query is executed through Spark; when run directly in sqlline, the query executes successfully without any problems.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Please let me know if you need any additional information. I'm happy to help.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Aug 2025 05:06:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412055#M253223</guid>
      <dc:creator>Arun_Tejasvi</dc:creator>
      <dc:date>2025-08-07T05:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting NullPointer Exception when a join query is executed on a Phoenix Database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412061#M253228</link>
      <description>&lt;P&gt;Have you tried to use the Phoenix–Spark connector using the following documentation - &lt;A href="https://docs.cloudera.com/cdp-private-cloud-base/7.1.9/phoenix-access-data/topics/phoenix-understanding-spark-connector.html" target="_self"&gt;https://docs.cloudera.com/cdp-private-cloud-base/7.1.9/phoenix-access-data/topics/phoenix-understanding-spark-connector.html&lt;/A&gt;?&lt;/P&gt;&lt;P&gt;If not, please give it a try and let us know if, for any reason, it does not meet your use cases.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 21:48:45 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412061#M253228</guid>
      <dc:creator>Anshul_Gupta</dc:creator>
      <dc:date>2025-08-08T21:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Getting NullPointer Exception when a join query is executed on a Phoenix Database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412062#M253229</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82089"&gt;@willx&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/93041"&gt;@ayushi&lt;/a&gt;&amp;nbsp;Hi! By any chance do you have some insights here? Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 22:54:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Getting-NullPointer-Exception-when-a-join-query-is-executed/m-p/412062#M253229</guid>
      <dc:creator>DianaTorres</dc:creator>
      <dc:date>2025-08-08T22:54:04Z</dc:date>
    </item>
  </channel>
</rss>

