mattcasters opened a new issue, #8283:
URL: https://github.com/apache/hop/issues/8283
### Apache Hop version?
2.19.0 (also present on current `main`)
### Java version?
21
### Operating system
Linux
### What happened?
Clicking **SQL** on Combination Lookup throws:
```
java.lang.NullPointerException: Cannot invoke
"org.apache.hop.pipeline.PipelineMeta.findDatabase(String,
org.apache.hop.core.variables.IVariables)" because the return value of
"org.apache.hop.pipeline.transform.TransformMeta.getParentPipelineMeta()" is
null
at
org.apache.hop.pipeline.transforms.combinationlookup.CombinationLookupMeta.getSqlStatements(CombinationLookupMeta.java:425)
at
org.apache.hop.pipeline.transforms.combinationlookup.CombinationLookupDialog.create(CombinationLookupDialog.java:900)
```
The dialog builds a **temporary** meta and wraps it in a new
`TransformMeta`. That wrapper never gets a parent pipeline:
```java
CombinationLookupMeta info = new CombinationLookupMeta();
getInfo(info);
TransformMeta transformMeta = new TransformMeta(..., name, info);
info.getSqlStatements(variables, pipelineMeta, transformMeta, prev,
metadataProvider);
```
`TransformMeta.setTransform()` does call `setParentTransformMeta(this)`, so
`getParentTransformMeta()` is non-null. `getParentPipelineMeta()` stays null.
`getSqlStatements` (and `analyseImpact`) then ignore the `pipelineMeta`
argument and go through the parent:
```java
DatabaseMeta databaseMeta =
getParentTransformMeta().getParentPipelineMeta().findDatabase(connectionName,
variables);
```
https://github.com/apache/hop/blob/main/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupMeta.java#L424-L425
https://github.com/apache/hop/blob/main/plugins/transforms/combinationlookup/src/main/java/org/apache/hop/pipeline/transforms/combinationlookup/CombinationLookupMeta.java#L676-L677
Dimension Lookup already does the right thing in `getSqlStatements`:
```java
DatabaseMeta databaseMeta = pipelineMeta.findDatabase(connection, variables);
```
https://github.com/apache/hop/blob/main/plugins/transforms/dimensionlookup/src/main/java/org/apache/hop/pipeline/transforms/dimensionlookup/DimensionLookupMeta.java#L891
### Steps to reproduce
1. Open a pipeline with a Combination Lookup that has a connection, table,
and incoming key fields.
2. Open the Combination Lookup dialog.
3. Click **SQL**.
**Expected:** SQL editor (or “no SQL needed”).
**Actual:** NPE as above.
### Suggested fix
Use the `pipelineMeta` passed into `getSqlStatements` / `analyseImpact`:
```java
DatabaseMeta databaseMeta = pipelineMeta.findDatabase(connectionName,
variables);
```
### Issue Priority
Priority: 2
### Issue Component
Component: Transforms
Component: Hop Gui
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]