NullPointerException on previews. 'Run' is fine. Prevents Reflection Creation

I am trying to create a virtual data set that is from multiple other virtual data sets.

When I select ‘Preview’, I always get a NullPointerException.

When I select ‘Run’, the query runs fine.

Below is the verbose error:

SYSTEM ERROR: NullPointerException

(com.dremio.exec.work.foreman.ForemanException) Unexpected exception during fragment initialization: failure during execution planning
com.dremio.exec.work.foreman.AttemptManager.run():369
com.dremio.common.concurrent.ContextMigratingExecutorService.lambda$decorate$3():192
java.util.concurrent.ThreadPoolExecutor.runWorker():1149
java.util.concurrent.ThreadPoolExecutor$Worker.run():624
java.lang.Thread.run():748
Caused By (com.dremio.common.exceptions.ExecutionSetupException) failure during execution planning
com.dremio.exec.maestro.MaestroServiceImpl.executeQuery():158
com.dremio.exec.work.foreman.AttemptManager.run():340
com.dremio.common.concurrent.ContextMigratingExecutorService.lambda$decorate$3():192
java.util.concurrent.ThreadPoolExecutor.runWorker():1149
java.util.concurrent.ThreadPoolExecutor$Worker.run():624
java.lang.Thread.run():748
Caused By (java.util.concurrent.ExecutionException) java.lang.NullPointerException
java.util.concurrent.CompletableFuture.reportGet():357
java.util.concurrent.CompletableFuture.get():1908
com.dremio.exec.maestro.MaestroServiceImpl.executeQuery():156
com.dremio.exec.work.foreman.AttemptManager.run():340
com.dremio.common.concurrent.ContextMigratingExecutorService.lambda$decorate$3():192
java.util.concurrent.ThreadPoolExecutor.runWorker():1149
java.util.concurrent.ThreadPoolExecutor$Worker.run():624
java.lang.Thread.run():748
Caused By (java.lang.NullPointerException) null

preview_nullpointer_9468f255-b832-407d-81cd-764e7e5b719f.zip (909.6 KB)
fullrun_successful_869e9134-bca6-4b20-922f-a20fc57fe505.zip (460.5 KB)

Update, this is now effecting runs and crippling our cluster.

Here is another version of the NullPointerException error. I have no idea how I am expected to diagnose this without any help from the error itself.
@balaji.ramaswamy What can I do to take this another step to remediate these NullPointerExceptions? This only began after upgrading from 4.1 -> 4.5

      PLAN ERROR: Error while applying rule Prel.NestedLoopJoinPrule, args [rel#344338015:JoinRel.LOGICAL.ANY([]).[](left=RelSubset#344337953,right=RelSubset#344338014,condition=AND(=($0, $4), =($3, $5), $9),joinType=right)]

SQL Query REFRESH REFLECTION ‘b6babdec-e981-41e7-a2e0-ccd1fbf4debc’ AS ‘f4ffd409-180e-403e-8401-72c1d54d4f3e’

(java.lang.RuntimeException) Error while applying rule Prel.NestedLoopJoinPrule, args [rel#344338015:JoinRel.LOGICAL.ANY([]).[](left=RelSubset#344337953,right=RelSubset#344338014,condition=AND(=($0, $4), =($3, $5), $9),joinType=right)]
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch():236
org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp():658
com.dremio.exec.planner.DremioVolcanoPlanner.findBestExp():83
org.apache.calcite.tools.Programs$RuleSetProgram.run():368
com.dremio.exec.planner.sql.handlers.PrelTransformer.lambda$transform$2():504
com.dremio.exec.planner.sql.handlers.PrelTransformer.doTransform():518
com.dremio.exec.planner.sql.handlers.PrelTransformer.transform():511
com.dremio.exec.planner.sql.handlers.PrelTransformer.convertToPrel():547
com.dremio.service.reflection.refresh.RefreshHandler.getPlan():183
com.dremio.exec.planner.sql.handlers.commands.HandlerToExec.plan():59
com.dremio.exec.work.foreman.AttemptManager.plan():418
com.dremio.exec.work.foreman.AttemptManager.lambda$run$1():327
com.dremio.service.commandpool.CommandWrapper.run():62
com.dremio.common.concurrent.ContextMigratingExecutorService.lambda$decorate$3():192
com.dremio.common.concurrent.ContextMigratingExecutorService$ComparableRunnable.run():174
java.util.concurrent.ThreadPoolExecutor.runWorker():1149
java.util.concurrent.ThreadPoolExecutor$Worker.run():624
java.lang.Thread.run():748
Caused By (java.lang.NullPointerException) null
com.dremio.sabot.op.join.JoinUtils.projectSwap():122
com.dremio.exec.planner.physical.NestedLoopJoinPrule.onMatch():106
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch():212
org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp():658
com.dremio.exec.planner.DremioVolcanoPlanner.findBestExp():83
org.apache.calcite.tools.Programs$RuleSetProgram.run():368
com.dremio.exec.planner.sql.handlers.PrelTransformer.lambda$transform$2():504
com.dremio.exec.planner.sql.handlers.PrelTransformer.doTransform():518
com.dremio.exec.planner.sql.handlers.PrelTransformer.transform():511
com.dremio.exec.planner.sql.handlers.PrelTransformer.convertToPrel():547
com.dremio.service.reflection.refresh.RefreshHandler.getPlan():183
com.dremio.exec.planner.sql.handlers.commands.HandlerToExec.plan():59
com.dremio.exec.work.foreman.AttemptManager.plan():418
com.dremio.exec.work.foreman.AttemptManager.lambda$run$1():327
com.dremio.service.commandpool.CommandWrapper.run():62
com.dremio.common.concurrent.ContextMigratingExecutorService.lambda$decorate$3():192
com.dremio.common.concurrent.ContextMigratingExecutorService$ComparableRunnable.run():174
java.util.concurrent.ThreadPoolExecutor.runWorker():1149
java.util.concurrent.ThreadPoolExecutor$Worker.run():624
java.lang.Thread.run():748
cb397089-d131-4c00-9c5a-a6726c1d26bc.zip (2.3 MB)

@jdingler

Looks like the planner is hitting a bug on preview, would you be able to provide us the profile for run so we can compare the plans?

Thanks
Bali

@balaji.ramaswamy
In the above comment there is a profile for a reflection refresh that fails due to a null pointer exception.

Attached to this is a NullPointerException attached to a full run. Note this is on a brand new cluster that we had to spin up due to significant issues around NullPointerExceptions on the old cluster.

d5692016-6c33-48ca-844a-feba3ad0c5c5.zip (289.7 KB)

@balaji.ramaswamy

Here is another example of a NullPointerException on a full run, this time from the original cluster:
060587bf-16cb-4316-8651-2eacc56022c2.zip (1.2 MB)