Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bindings/python/fluss/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ class Schema:
def get_column_names(self) -> List[str]: ...
def get_column_types(self) -> List[str]: ...
def get_columns(self) -> List[Tuple[str, str]]: ...
def get_primary_keys(self) -> List[str]: ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the website's api reference documentation be updated as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

def __str__(self) -> str: ...

class TableDescriptor:
Expand Down
8 changes: 7 additions & 1 deletion bindings/python/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,13 @@ impl Schema {
.collect()
}

Copilot AI Mar 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema.get_primary_keys() is missing a Rust doc comment (/// ...) while the adjacent Schema methods have doc comments. Adding one keeps the generated Python docstrings/help output consistent across the API surface.

Suggested change
/// Get primary key column names

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema.get_primary_keys() is missing a Rust doc comment (/// ...) while the adjacent Schema methods have doc comments. Adding one keeps the generated Python docstrings/help output consistent across the API surface.

Suggested change
/// Get primary key column names

Added

// TODO: support primaryKey
/// Get primary key column names, returns empty list if no primary key is defined
fn get_primary_keys(&self) -> Vec<String> {
self.__schema
.primary_key()
.map(|pk| pk.column_names().to_vec())
.unwrap_or_default()
}
Comment on lines +224 to +229

Copilot AI Mar 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New Python API method Schema.get_primary_keys() is added in the PyO3 bindings, but the package type stubs (bindings/python/fluss/__init__.pyi) still define Schema without this method. This will leave typing users (mypy/IDE autocomplete) out of sync with runtime behavior; please update the stub to include def get_primary_keys(self) -> List[str]: ... for Schema.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New Python API method Schema.get_primary_keys() is added in the PyO3 bindings, but the package type stubs (bindings/python/fluss/__init__.pyi) still define Schema without this method. This will leave typing users (mypy/IDE autocomplete) out of sync with runtime behavior; please update the stub to include def get_primary_keys(self) -> List[str]: ... for Schema.

Added


fn __str__(&self) -> String {
format!("Schema: columns={:?}", self.get_columns())
Expand Down
1 change: 1 addition & 0 deletions bindings/python/test/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ async def test_create_table(admin):
),
primary_keys=["id"],
)
assert schema.get_primary_keys() == ["id"]

table_descriptor = fluss.TableDescriptor(
schema,
Expand Down
37 changes: 37 additions & 0 deletions bindings/python/test/test_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

"""Unit tests for Schema (no cluster required)."""

import pyarrow as pa

import fluss


def test_get_primary_keys():
fields = pa.schema([
pa.field("id", pa.int32()),
pa.field("name", pa.string()),
])

schema_with_pk = fluss.Schema(fields, primary_keys=["id"])
assert schema_with_pk.get_primary_keys() == ["id"]

schema_without_pk = fluss.Schema(fields)
assert schema_without_pk.get_primary_keys() == []


2 changes: 2 additions & 0 deletions website/docs/user-guide/python/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ for record in scan_records:
| `Schema(schema: pa.Schema, primary_keys=None)` | Create from PyArrow schema |
| `.get_column_names() -> list[str]` | Get column names |
| `.get_column_types() -> list[str]` | Get column type names |
| `.get_columns() -> list[tuple[str, str]]` | Get `(name, type)` pairs |
| `.get_primary_keys() -> list[str]` | Get primary key columns |

## `TableDescriptor`

Expand Down
Loading