Skip to content

feat(cli): add metaxy metadata read command - #1109

Open
AnkitSharma-29 wants to merge 26 commits into
anam-org:mainfrom
AnkitSharma-29:feat/metadata-read
Open

feat(cli): add metaxy metadata read command#1109
AnkitSharma-29 wants to merge 26 commits into
anam-org:mainfrom
AnkitSharma-29:feat/metadata-read

Conversation

@AnkitSharma-29

Copy link
Copy Markdown
Contributor

This PR implements the metadata read command as requested in #706. It allows users to quickly execute arbitrary SQL queries against feature metadata using DuckDB and Polars. The command supports a simplified interface with --filter and --select arguments, as well as an advanced --query argument. Output can be directed to stdout or a file in markdown, json, csv, or parquet formats. Comprehensive unit tests have been added in tests/cli/test_cli_metadata_read.py to ensure all functionality works as expected.

@codecov

codecov Bot commented Mar 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@danielgafni danielgafni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

Overall looking good, I suggested a few improvements.

Also, please improve the tests to assert more about the data - ideally the full dataframe for Parquet (json and csv will probably lose proper datatypes)

Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread tests/cli/test_cli_metadata_read.py Outdated

@danielgafni danielgafni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Left a bunch of comments

Overall this looks suspiciously AI-ish, please review the output better

Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated

@danielgafni danielgafni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. Minor comments
  2. Please consolidate Literal["csv", "json", "parquet", "markdown"] into WriteFormat: TypeAlias = ... at the top of this module
  3. I think the tests should be refactored:
    1. pamaterization: instead of defining a single test for every combinations of format and output parameters, make a single test using @pytest.mark.parametrize for both parameters.
    2. data: I think it should be possible to make a single shared @pytest.fixture for the datafarme used in these tests.
  4. When --query is used with a non-Ibis store, please let's not use Polars at all. Just use duckdb instead. We can fail with a clear message if duckdb is not available. This is because Polars' support for SQL is way behind DuckDB's.
  5. Since 0.1.7 has been released and Metaxy aims to eventually support Map types by default, let's replace all collect_to_polars with _collect_to_arrow, and use DuckDB instead of Polars for writes. For Markdown we can use the Markdown extension. Avoid using Polars completely, let's do not have the import polars at all. This is because Polars doesn't support the Map type.

I am documenting references to all of these docs for educational purposes since previously you said you wanted to learn. I assume good faith here so please take your time to go though them and understand what's expected without AI assistance :) As you can see AI is struggling to write clean (or even correct at all) code without proper human guidance and is useless without it.

Comment thread src/metaxy/cli/metadata.py
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread src/metaxy/cli/metadata.py Outdated
Comment thread tests/cli/test_cli_metadata_read.py Outdated
Comment thread tests/cli/test_cli_metadata_read.py Outdated
Comment thread tests/cli/test_cli_metadata_read.py Outdated
Comment thread tests/cli/test_cli_metadata_read.py Outdated
Comment thread tests/cli/test_cli_metadata_read.py Outdated
@AnkitSharma-29

Copy link
Copy Markdown
Contributor Author
  1. Minor comments

  2. Please consolidate Literal["csv", "json", "parquet", "markdown"] into WriteFormat: TypeAlias = ... at the top of this module

  3. I think the tests should be refactored:

    1. pamaterization: instead of defining a single test for every combinations of format and output parameters, make a single test using @pytest.mark.parametrize for both parameters.
    2. data: I think it should be possible to make a single shared @pytest.fixture for the datafarme used in these tests.
  4. When --query is used with a non-Ibis store, please let's not use Polars at all. Just use duckdb instead. We can fail with a clear message if duckdb is not available. This is because Polars' support for SQL is way behind DuckDB's.

  5. Since 0.1.7 has been released and Metaxy aims to eventually support Map types by default, let's replace all collect_to_polars with _collect_to_arrow, and use DuckDB instead of Polars for writes. For Markdown we can use the Markdown extension. Avoid using Polars completely, let's do not have the import polars at all. This is because Polars doesn't support the Map type.

I am documenting references to all of these docs for educational purposes since previously you said you wanted to learn. I assume good faith here so please take your time to go though them and understand what's expected without AI assistance :) As you can see AI is struggling to write clean (or even correct at all) code without proper human guidance and is useless without it.

Thanks for the docs really appreciate it. I’ll go through them and make sure I understand everything before updating the PR.

I’m trying to keep AI usage minimal. Earlier I got stuck while updating the PR and used Antigravity, which may have unintentionally changed some code. I’ll review and fix it properly.

AnkitSharma-29 added a commit to AnkitSharma-29/metaxy that referenced this pull request Mar 30, 2026
@danielgafni danielgafni changed the title feat: implement metaxy metadata read command (#706) feat(cli): add metaxy metadata read command Mar 30, 2026
@danielgafni

Copy link
Copy Markdown
Collaborator

@AnkitSharma-29 fyi once #1130 lands you'll need to use it as from metaxy._utils import collect_to_arrow

The MetadataStore refactor on main moved metaxy.metadata_store.ibis to
metaxy.ext.ibis.metadata_store. Update the metadata read command's import
accordingly to resolve the typecheck failure.

@danielgafni danielgafni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, two small comments left!

Comment thread src/metaxy/cli/metadata.py Outdated
Comment on lines +906 to +908
except Exception:
# Fallback: use DuckDB's built-in display
md = str(con.query("SELECT * FROM _output"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this should just fail with an error. The current fallback doesn't produce Markdown while the user has clearly requested it.

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.

Good catch....removed the fallback entirely so it no longer emits non-markdown output. While fixing it I found the install_extension("markdown") call was the actual cause of the fallback being hit, and it's unnecessary since markdown is rendered via pandas to_markdown(). It now produces real Markdown and fails loudly if rendering can't happen. Added a test covering the failure case.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please do not use Pandas. Just fix the markdown dudkcb extension installation instead (if that's a thing). Avoid Pandas at all cost.

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.

Removed pandas from the markdown output it's now generated natively from the DuckDB Arrow result, no to_markdown(). There's no installable DuckDB markdown extension, so the table is built inline. pushed in ddff9f4.

Comment thread src/metaxy/cli/metadata.py Outdated
@AnkitSharma-29

Copy link
Copy Markdown
Contributor Author

Thanks, two small comments left!

Thanks! Both addressed in 261bec5.

Build the markdown table directly from the DuckDB Arrow result instead
of pandas to_markdown(), per maintainer feedback to avoid pandas.
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.

2 participants