Skip to content

Conversation

@xincheng123
Copy link

🎨 Enhance

  • Code style optimization
  • Refactoring
  • Change the UI
  • Improve the performance
  • Type optimization

📝 嵌套字段支持(Nested Fields)

对S2 内核进行改造, 支持通过“路径”读取嵌套数据结构中的字段值, 嵌套层级不限(兼容原有平铺字段)。

示例数据:

const data = [
  {
    name: '中国',
    user: { region: '华东', city: '上海' },
    metrics: { price: 100, city: { address: '测试名称' } },
  },
];

const s2DataConfig = {
  data,
  fields: {
    rows: ['name', 'user.region', 'user.city'],
    columns: [],
    values: ['metrics.price', 'metrics.city.address'],
  },
};

注意事项:

  • 行列头与数值字段均可使用路径(如 user.regionmetrics.city.addressmetrics.city.address[0].name)。
  • 排序、筛选、导出与格式化等流程将基于相同的路径取值逻辑。
  • 平铺字段(不含 . 或下标)仍走快速访问路径,性能无损。

🔗 Related issue link

ref #3231

🔍 Self-Check before the merge

  • Add or update relevant docs.
  • Add or update relevant demos.
  • Add or update test case.
  • Add or update relevant TypeScript definitions.

@github-actions
Copy link
Contributor

你好 @xincheng123,非常感谢你的贡献.
为了让代码更健壮, 请根据 贡献指南 补充相应单元测试 (文档改动或其他特殊场景除外), 如果有 API 改动, 请修改 相应的文档.
同时请检查 linttest 相关 CI 是否通过, 如果失败, 请点击 [Details] 按钮查看, 并根据日志修复.

Hello, @xincheng123, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the docs if there are API changes.
At the same time, please check whether the CI related to lint and test passes. If the CI fails, please click [Details] button to check and repair according to the log.

@github-actions github-actions bot added the pr(feature) new feature label Oct 16, 2025
@github-actions github-actions bot requested a review from Alexzjt October 16, 2025 06:30
@github-actions github-actions bot added the next 2.0-next 版本的问题 label Oct 16, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @xincheng123, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在增强 S2 内核的数据处理能力,使其能够灵活地处理任意层级的嵌套数据结构。通过引入基于路径的字段值读取机制,用户现在可以使用点分隔符或数组索引来指定数据字段,从而极大地提升了数据配置的灵活性和表达力。这一改进确保了 S2 能够适应更复杂的数据模型,同时保持了对现有平铺数据结构的兼容性和性能。

Highlights

  • 嵌套数据结构支持: S2 内核现在支持通过“路径”读取嵌套数据结构中的字段值,例如 'a.b.c' 或 'a.b[0].c',支持任意嵌套层级。
  • 兼容性与性能: 此功能完全兼容原有平铺字段的访问方式,对不含 '.' 或 '[' 的平铺字段访问性能无损。
  • 核心流程集成: 新的路径访问逻辑已应用于行列头、数值字段、排序、筛选、导出和格式化等 S2 核心流程中。
  • 新增工具函数: 引入了 getByPathhasByPath 辅助函数,用于安全地访问和检查对象中的嵌套路径。
  • 代码重构与测试: 重构了 CellDataBaseDataSetTableDataSetpivot-data-set 等关键模块以集成新的路径访问能力,并为新功能添加了全面的单元测试。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

这个 PR 很好地实现了通过路径字符串访问嵌套数据的功能,这是一个很棒的增强。代码结构清晰,通过引入 getByPathhasByPath 辅助函数,将嵌套访问逻辑集中处理,并对平铺字段做了快速路径优化,考虑了性能。同时,修改也覆盖了排序、筛选、导出等多个场景,考虑得很周全,并且添加了相应的单元测试。

我发现了一个潜在的小问题,在 hasByPath 函数的实现中,快速路径和慢速路径的行为存在不一致,具体请看我的评论。修复后,这个功能就更完美了。

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@xincheng123 xincheng123 removed their assignment Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next 2.0-next 版本的问题 pr(feature) new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant