apache / apache/fluss

[rust] get_table returns InvalidTableException for a nonexistent table

Open
#4,270 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.1k
Forks
625
Avg merge
3d 14h
Merged PRs (30d)
97

Description

### Search before asking

- [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar.

### Fluss version

main (development)

### Please describe the bug 🐞

When the Rust client calls `FlussConnection::get_table` for a table that does not exist, it returns the generic `InvalidTableException` instead of `TableNotExist`.

This prevents applications from reliably distinguishing a missing table from other metadata or network-related failures.

### Expected behavior

- A nonexistent table returns `FlussError::TableNotExist`.
- Network, timeout, and other RPC errors retain their original error type.

### Steps to reproduce

```rust
let table_path = TablePath::new("fluss", "nonexistent_table");
let result = connection.get_table(&table_path).await;

let error = match result {
Ok(_) => panic!("getting a nonexistent table should fail"),
Err(error) => error,
};

assert_eq!(
error.api_error(),
Some(FlussError::TableNotExist)
);
```
### Actual result

FlussError::InvalidTableException

### Expected result

FlussError::TableNotExist

### Solution

Before refreshing the table metadata, use the authoritative GetTable RPC to check whether the table exists.

If `GetTable` indicates that the table does not exist, return a typed `Error::table_not_exist` error. Propagate all other RPC and network errors unchanged.

Conceptually:
```rust
if metadata.fetch_table_id(table_path).await?.is_none() {
return Err(Error::table_not_exist(format!(
"Table not found: {table_path}"
)));
}

metadata.update_table_metadata(table_path).await?;
```
This preserves the distinction between a missing table and transient network or server failures.

Add an integration test verifying that `FlussConnection::get_table` returns `FlussError::TableNotExist` for a nonexistent table.

### Are you willing to submit a PR?

- [x] I'm willing to submit a PR!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Rust client’s FlussConnection::get_table and trace metadata.fetch_table_id and metadata.update_table_metadata. Run or add the integration test described in the issue, using a nonexistent TablePath. Done means missing tables return FlussError::TableNotExist while network, timeout, and other RPC errors remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.