apache / apache/cloudberry

[Bug] The plan generated by ORCA misses `resorigtbl` in TargetEntry when filter is false

Open
#1,072 1 comment 0 reactions 0 assignees View on GitHub
type: Bug type: Orca
Dominant language
C
Stars
1.4k
Forks
247
Avg merge
4d 3h
Merged PRs (30d)
39

Description

### Apache Cloudberry version

cloudberry: Latest
jdbc--42.7.5

### What happened

```
import java.sql.*;

public class JdbcTest {
public static void main(String[] args) {
/* create table tab_jdbc_metadata (a numeric(38,4) not null, b int not null); */

try (Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/gpadmin", "gpadmin", "gpadmin")) {

System.out.println("Connected to PostgreSQL database!");

Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM tab_jdbc_metadata WHERE 1=0");

ResultSetMetaData metaData = resultSet.getMetaData();
int ncolumns = metaData.getColumnCount();
for (int i = 1; i <= ncolumns; i++) {
System.out.println("Column name: " + metaData.getColumnName(i) +
", Precision: " +metaData.getPrecision(i) +
", Scale: " + metaData.getScale(i) +
", Nullable: " + metaData.isNullable(i));
}
} catch (Exception e) {
System.out.println("Connection failure.");
e.printStackTrace();
}
}
}
```
expected result is :
```
Column name: a, Precision: 38, Scale: 4, Nullable: 0
Column name: b, Precision: 10, Scale: 0, Nullable: 0
```
but result is in cloudberry is :
```
Column name: a, Precision: 38, Scale: 4, Nullable: 2
Column name: b, Precision: 10, Scale: 0, Nullable: 2

### What you think should happen instead

_No response_

### How to reproduce

see above

### Operating System

centos7/macos

### Anything else

_No response_

### Are you willing to submit PR?

- [ ] Yes, I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/cloudberry/blob/main/CODE_OF_CONDUCT.md).

Contributor guide

Open the contributing guide

Research direction

Begin with the JDBC reproduction in the issue and compare ResultSetMetaData.isNullable() for the WHERE 1=0 query. Then trace the ORCA-generated plan and its TargetEntry handling when the filter is false. Done means the metadata reports Nullable: 0 for both columns, matching the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.