Skip to content

Add extended table metadata retrieval and models for columns and option sets#132

Open
maksii wants to merge 7 commits intomicrosoft:mainfrom
maksii:feature/metadata
Open

Add extended table metadata retrieval and models for columns and option sets#132
maksii wants to merge 7 commits intomicrosoft:mainfrom
maksii:feature/metadata

Conversation

@maksii
Copy link

@maksii maksii commented Feb 28, 2026

This PR extends the Dataverse SDK’s table metadata APIs to support richer metadata retrieval (columns, relationships, and option sets) and adds new metadata models plus corresponding unit tests.

Add extended table metadata retrieval and models for columns and option sets

  • Implemented methods to fetch detailed metadata for tables, including columns and relationships.
  • Introduced ColumnMetadata, OptionItem, and OptionSetInfo models to represent column and option set data structures.
  • Updated get method in TableOperations to support optional parameters for including columns and relationships in the response.
  • Enhanced tests to cover new functionality and ensure backward compatibility.

This update improves the SDK's ability to interact with Dataverse metadata, providing richer data for developers.

maksii and others added 6 commits February 28, 2026 14:24
…on sets

- Implemented methods to fetch detailed metadata for tables, including columns and relationships.
- Introduced `ColumnMetadata`, `OptionItem`, and `OptionSetInfo` models to represent column and option set data structures.
- Updated `get` method in `TableOperations` to support optional parameters for including columns and relationships in the response.
- Enhanced tests to cover new functionality and ensure backward compatibility.

This update improves the SDK's ability to interact with Dataverse metadata, providing richer data for developers.
Co-authored-by: maksii <1761348+maksii@users.noreply.github.com>
Fix spurious `columns_created` in `get()` result and reduce cyclomatic complexity
- Introduced new test data fixtures in `tests/fixtures/test_data.py` for various metadata attributes, including columns, option sets, and relationships.
- Updated `tests/unit/models/test_metadata.py` to utilize the new fixtures for testing `ColumnMetadata` and `OptionSetInfo` classes, improving test coverage for primary name columns, picklist columns, and status/state option sets.
- Enhanced `tests/unit/test_tables_operations.py` to incorporate fixtures for table operations, ensuring accurate testing of column retrieval, relationship listing, and table metadata.
- Refactored existing tests to replace hardcoded data with structured test data from the new fixtures, promoting maintainability and clarity in test cases.
- Updated the docstring to clarify the types of columns supported, including Picklist, MultiSelect, Boolean, Status, and State.
- Improved descriptions of the return values for better understanding of the method's functionality.
Copilot AI review requested due to automatic review settings February 28, 2026 13:41
@maksii maksii requested a review from a team as a code owner February 28, 2026 13:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extends the Dataverse SDK metadata surface area to support richer table metadata retrieval (columns, relationships, option sets) and introduces new strongly-typed metadata models, with accompanying docs and unit tests.

Changes:

  • Added extended table metadata retrieval via TableOperations.get(..., select/include_columns/include_relationships) plus new helpers (get_columns, get_column, get_column_options, list_relationships).
  • Introduced new metadata models: ColumnMetadata, OptionItem, OptionSetInfo.
  • Expanded fixtures and added/updated unit tests and documentation examples for the new APIs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/PowerPlatform/Dataverse/operations/tables.py Adds extended table/column/relationship/option-set APIs on the public tables namespace.
src/PowerPlatform/Dataverse/data/_odata.py Implements low-level Web API calls for rich entity metadata, columns, relationships, and option sets.
src/PowerPlatform/Dataverse/models/metadata.py Adds new dataclass-based metadata models and API-response mapping helpers.
src/PowerPlatform/Dataverse/common/constants.py Adds constants for attribute metadata cast types and attribute type codes.
tests/unit/test_tables_operations.py Adds unit tests for extended get() behavior and new tables methods.
tests/unit/models/test_metadata.py Adds unit tests for the new metadata model mappers.
tests/fixtures/test_data.py Adds realistic column/option set/relationship fixture payloads and table list entries.
tests/fixtures/__init__.py Initializes the fixtures package.
README.md Documents new metadata retrieval capabilities with examples.
.claude/skills/dataverse-sdk-use/SKILL.md Updates skill documentation with new metadata APIs and examples.
Comments suppressed due to low confidence (2)

src/PowerPlatform/Dataverse/data/_odata.py:1525

  • Using set(select) and set union to build $select makes the projected field order non-deterministic. This can cause noisy diffs/logs and can interfere with any request caching keyed by URL. Prefer an order-preserving de-duplication strategy (e.g., base fields first, then user-provided fields in their original order).
        if select:
            base_fields = {"MetadataId", "LogicalName", "SchemaName", "EntitySetName"}
            merged = list(base_fields | set(select))
            params["$select"] = ",".join(merged)

src/PowerPlatform/Dataverse/data/_odata.py:1653

  • The docstring for _get_column_optionset says it only supports Picklist/MultiSelectPicklist/Boolean, but the implementation also attempts Status and State casts (and the public API advertises Status/State support). Update the docstring to reflect the actual supported attribute types and the expected 400/404 behavior for failed casts.
        """Get the option set definition for a Picklist, MultiSelectPicklist, or Boolean column.

        :param table_schema_name: Schema name of the table.
        :type table_schema_name: ``str``
        :param column_logical_name: Logical name of the column.
        :type column_logical_name: ``str``

        :return: Raw option set metadata dict, or ``None`` if not found or not an option-set column.
        :rtype: ``dict[str, Any]`` | ``None``

        :raises HttpError: If the request fails (non-400/404).
        """

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants