Conversation
- Expand .gitignore with comprehensive rules
- Add enhanced dict access for Table class - Update tests to use new access pattern
There was a problem hiding this comment.
cubic analysis
1 issue found across 4 files • Review in cubic
React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.
chidian/table.py
Outdated
| ["John", "Jane", "Bob"] | ||
| """ | ||
| # Check if this is a path expression (contains dot) | ||
| if "." in key: |
There was a problem hiding this comment.
Calling super().getitem for keys that do not contain a dot breaks the documented behaviour of allowing column access through table["column"]. When the key is a plain column name (e.g. "name") it should delegate to get(), not to the parent dict, otherwise a KeyError will be raised unless a row happens to share that key. The condition should also treat any key that is not a row identifier (doesn't start with "$") as a path expression.
Prompt for AI agents
Address the following comment on chidian/table.py at line 759:
<comment>Calling super().__getitem__ for keys that do not contain a dot breaks the documented behaviour of allowing column access through table["column"]. When the key is a plain column name (e.g. "name") it should delegate to get(), not to the parent dict, otherwise a KeyError will be raised unless a row happens to share that key. The condition should also treat any key that is not a row identifier (doesn't start with "$") as a path expression.</comment>
<file context>
@@ -335,6 +335,434 @@ def group_by(self, path: str) -> dict[Any, "Table"]:
return {key: Table(rows) for key, rows in groups.items()}
+ def extract(self, path: str) -> "Table":
+ """
+ Extract values from all rows using a path and return as a new Table.
+
+ This method is particularly useful for extracting nested structures
+ like FHIR Bundle entries or other collections within your data.
</file context>
Suggested change
| if "." in key: | |
| if "." in key or not key.startswith("$"): |
- Refactor Table class to remove dict inheritance - Improve row key management - Modify test cases for new implementation - Bump package version to 0.1.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes N/A
Background
The
Tableclass is a sparse table (a list of dictionaries with some helper wrappers). Used more DSL-like features to make it neaterDesign (high-level)
get,__getitem__, etc.joinhelper function that is SQL-like and just does left & inner joinsOther notes
Summary by cubic
Added new Table methods for extracting data, joining tables, and dot notation access, making data manipulation easier and more flexible.