apache / apache/kyuubi

[Bug][Lineage] Collect tables referenced in filter conditions for lineage analysis

Open
#7,206 4 comments 0 reactions 0 assignees View on GitHub
kind:bug priority:major
Dominant language
Scala
Stars
2.4k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

### Search before asking

- [x] I have searched in the [issues](https://github.com/apache/kyuubi/issues?q=is%3Aissue) and found no similar issues.

### Describe the bug

When a SQL query contains a subquery in the WHERE clause, the table referenced within the subquery are not included in the extracted upstream table lineage.

For example,
```sql
insert overwrite v2_catalog.db.tb3
select *
from v2_catalog.db.tb1 t1
where exists (select 1 from v2_catalog.db.tb2 t2 where t2.col1 = t1.col1);
```
the current result is:
```scala
Lineage(
List("v2_catalog.db.tb1"),
List("v2_catalog.db.tb3"),
List(
("v2_catalog.db.tb3.col1", Set("v2_catalog.db.tb1.col1")),
("v2_catalog.db.tb3.col2", Set("v2_catalog.db.tb1.col2")),
("v2_catalog.db.tb3.col3", Set("v2_catalog.db.tb1.col3")))))
```
the output omits table `v2_catalog.db.tb2`, which is referenced in the filter condition.

So I propose to add a new a configuration to control whether to collect the tables referenced in filter conditions as lineage input tables

### Affects Version(s)

1.11.0

### Kyuubi Server Log Output

```logtalk

```

### Kyuubi Engine Log Output

```logtalk

```

### Kyuubi Server Configurations

```yaml

```

### Kyuubi Engine Configurations

```yaml

```

### Additional context

_No response_

### Are you willing to submit PR?

- [x] Yes. I would be willing to submit a PR with guidance from the Kyuubi community to fix.
- [ ] No. I cannot submit a PR at this time.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided INSERT query and trace the lineage extraction path for tables referenced inside WHERE subqueries. Identify how the proposed configuration should control this behavior; done means the default or configured behavior is explicit and table v2_catalog.db.tb2 appears as an upstream lineage input when enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala, sql
Domain
data-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.