-
Notifications
You must be signed in to change notification settings - Fork 44
feat(python): add get_primary_keys() method to Schema class #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b569dd4
2042157
1bf2dda
0a477cd
c45a7f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -220,7 +220,13 @@ impl Schema { | |||||||
| .collect() | ||||||||
| } | ||||||||
|
|
||||||||
|
||||||||
| /// Get primary key column names |
There was a problem hiding this comment.
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
Copilot
AI
Mar 8, 2026
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 defineSchemawithout this method. This will leave typing users (mypy/IDE autocomplete) out of sync with runtime behavior; please update the stub to includedef get_primary_keys(self) -> List[str]: ...forSchema.
Added
| 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() == [] | ||
|
|
||
|
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1