Skip to content

feat: implement MOL data type insert support in Go layer - #46957

Open
862103595 wants to merge 4 commits into
milvus-io:masterfrom
862103595:feat/mol-insert-implementation
Open

feat: implement MOL data type insert support in Go layer#46957
862103595 wants to merge 4 commits into
milvus-io:masterfrom
862103595:feat/mol-insert-implementation

Conversation

@862103595

@862103595 862103595 commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Related to

Design Doc

This PR is part of the MOL feature stack and should be reviewed together with the design doc above.

Summary

This PR implements the insert path support for MOL (Molecular) data type in the Go layer of Milvus. It enables users to insert molecular data (SMILES strings) into collections, with proper validation, serialization, and binlog persistence.

Changes

1. Proxy Layer - Data Validation (internal/proxy/validate_util.go)

  • Added checkMOLFieldData() function to validate MOL field data
  • Converts SMILES strings to pickle format for storage
  • Validates data format and handles errors appropriately
  • Ensures data integrity before insertion

2. Storage Layer - Data Structures and Operations

Core Data Structure (internal/storage/insert_data.go)

  • Added MolFieldData struct to represent MOL field data
  • Implemented all required FieldData interface methods:
    • RowNum(), GetRow(), GetDataRows()
    • AppendRow(), AppendRows(), AppendDataRows()
    • AppendValidDataRows(), GetDataType()
    • GetMemorySize(), GetRowSize(), GetNullable()

Serialization (internal/storage/data_codec.go)

  • Added MOL type handling in AddFieldDataToPayload() for binlog serialization
  • Added MOL type handling in AddInsertData() for data insertion

Payload Operations

  • Writer (internal/storage/payload_writer.go):

    • Added AddOneMolToPayload() method to write MOL data to payload
    • Added MOL type support in AddDataToPayloadForUT()
    • Added MOL type mapping in MilvusDataTypeToArrowType()
  • Reader (internal/storage/payload_reader.go):

    • Added GetMolFromPayload() method to read MOL data from payload
    • Added MOL type handling in GetDataFromPayload()

Data Conversion (internal/storage/utils.go)

  • Added MOL type conversion in ColumnBasedInsertMsgToInsertData() - converts proto FieldData to MolFieldData
  • Added MOL type conversion in TransferInsertDataToInsertRecord() - converts MolFieldData back to proto FieldData
  • Added mergeMolField() function for merging MOL field data

Other Utilities

  • Data Sorting (internal/storage/data_sorter.go): Added MOL type support for data sorting
  • Binlog Printing (internal/storage/print_binlog.go): Added MOL type support for binlog debugging
  • Serialization (internal/storage/serde.go): Added MOL type support
  • Payload Interface (internal/storage/payload.go): Added MOL methods to interfaces

Implementation Details

Data Flow

  1. Proxy Layer: Validates MOL field data and converts SMILES to pickle format
  2. Storage Layer:
    • Creates MolFieldData structure from proto FieldData
    • Serializes data to binlog using payload writer
    • Supports reading from binlog using payload reader
    • Handles data conversion between proto and internal formats

Key Features

  • SMILES Support: Accepts SMILES strings and converts them to binary format
  • Nullable Support: Full support for nullable MOL fields
  • Binlog Persistence: Data can be serialized to and deserialized from binlog
  • Type Safety: Proper type checking and conversion throughout the pipeline

Files Changed

  • internal/proxy/validate_util.go (+37 lines)
  • internal/storage/data_codec.go (+22 lines)
  • internal/storage/data_sorter.go (+3 lines)
  • internal/storage/insert_data.go (+5 lines)
  • internal/storage/payload.go (+2 lines)
  • internal/storage/payload_reader.go (+22 lines)
  • internal/storage/payload_writer.go (+44 lines)
  • internal/storage/print_binlog.go (+16 lines)
  • internal/storage/serde.go (+1 line)
  • internal/storage/utils.go (+40 lines)

Total: 10 files changed, 192 insertions(+)

Notes

  • This PR focuses on the Go layer implementation only
  • C++ layer support (SegCore memory storage) will be implemented in a separate PR
  • The implementation supports the complete insert path from Proxy validation to binlog persistence
  • SMILES strings are converted to pickle format for efficient storage and retrieval

@sre-ci-robot
sre-ci-robot requested review from czs007 and sunby January 9, 2026 09:57
@sre-ci-robot sre-ci-robot added the size/L Denotes a PR that changes 100-499 lines. label Jan 9, 2026
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @862103595, 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!

This pull request significantly enhances Milvus's Go layer by introducing comprehensive support for inserting Molecular (MOL) data. It establishes a complete data flow, from initial validation of SMILES strings in the proxy layer and their conversion to a more efficient pickle format, through to the robust handling and persistence of this data within the storage layer. This enables users to seamlessly store and manage molecular information, ensuring data integrity and efficient binlog serialization.

Highlights

  • MOL Data Type Support: Implemented full insert path support for the Molecular (MOL) data type in the Go layer of Milvus, enabling users to insert molecular data (SMILES strings) into collections.
  • SMILES to Pickle Conversion: The proxy layer now validates incoming SMILES strings and converts them into a more efficient pickle binary format for storage, ensuring data integrity before insertion.
  • Comprehensive Storage Integration: Introduced a dedicated MolFieldData struct and integrated MOL type handling across various storage components, including data serialization, payload writing and reading, data conversion between proto and internal formats, data sorting, and binlog persistence.
  • Nullable Field Support: Ensured full support for nullable MOL fields throughout the entire insertion process, from validation to storage.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

@mergify

mergify Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

@862103595

Invalid PR Title Format Detected

Your PR submission does not adhere to our required standards. To ensure clarity and consistency, please meet the following criteria:

  1. Title Format: The PR title must begin with one of these prefixes:
  • feat: for introducing a new feature.
  • fix: for bug fixes.
  • enhance: for improvements to existing functionality.
  • test: for add tests to existing functionality.
  • doc: for modifying documentation.
  • auto: for the pull request from bot.
  • build(deps): for dependency updates from Dependabot.
  1. Description Requirement: The PR must include a non-empty description, detailing the changes and their impact.

Required Title Structure:

[Type]: [Description of the PR]

Where Type is one of feat, fix, enhance, test or doc.

Example:

enhance: improve search performance significantly 

Please review and update your PR to comply with these guidelines.

@862103595 862103595 changed the title implement MOL data type insert support in Go layer feat: implement MOL data type insert support in Go layer Jan 9, 2026
@sre-ci-robot

Copy link
Copy Markdown
Contributor

[ci-v2-notice]
Notice: New ci-v2 system is enabled for this PR.

To rerun ci-v2 checks, comment with:

  • /ci-rerun-code-check // for ci-v2/code-check
  • /ci-rerun-build // for ci-v2/build
  • /ci-rerun-ut-integration // for ci-v2/ut-integration, will rerun ci-v2/build
  • /ci-rerun-ut-go // for ci-v2/ut-go, will rerun ci-v2/build
  • /ci-rerun-ut-cpp // for ci-v2/ut-cpp
  • /ci-rerun-ut // for all ci-v2/ut-integration, ci-v2/ut-go, ci-v2/ut-cpp, will rerun ci-v2/build
  • /ci-rerun-e2e-arm // for ci-v2/e2e-arm
  • /ci-rerun-e2e-default // for ci-v2/e2e-default

If you have any questions or requests, please contact @zhikunyao.

@mergify mergify Bot added kind/feature Issues related to feature request from users and removed do-not-merge/invalid-pr-format labels Jan 9, 2026
@mergify

mergify Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

@862103595 Please associate the related issue to the body of your Pull Request. (eg. "issue: #")

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for the MOL (Molecular) data type in the Go layer, enabling the insertion of SMILES strings. The changes are comprehensive, covering data validation, serialization, and binlog persistence. The implementation correctly follows the patterns established for other data types in the codebase. My review focuses on improving maintainability by addressing code duplication and enhancing error reporting for better user feedback. I've identified a few areas where refactoring could reduce redundancy and a specific case where error handling could be more precise.

log.Warn("insert invalid MOL data!! Transform to pickle failed",
zap.Error(err),
zap.Int("index", index))
return merr.WrapErrIoFailedReason(err.Error())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The error returned here, merr.WrapErrIoFailedReason, suggests an I/O failure. However, a failure in common.ConvertSMILESToPickle is more likely due to an invalid SMILES string, which is a user input error. It would be more accurate to use merr.WrapErrParameterInvalid to provide a clearer error message to the user. This will improve error diagnostics.

Suggested change
return merr.WrapErrIoFailedReason(err.Error())
return merr.WrapErrParameterInvalid("valid SMILES string", "invalid SMILES string", fmt.Sprintf("failed to convert SMILES to pickle at index %d: %v", index, err))

Comment on lines +262 to +280
case schemapb.DataType_Mol:
val, ok := data.([]byte)
if !ok {
return merr.WrapErrParameterInvalidMsg("incorrect data type")
}
isValid := true
if len(validData) > 1 {
return merr.WrapErrParameterInvalidMsg("wrong input length when add data to payload")
}
if len(validData) == 0 && w.nullable {
return merr.WrapErrParameterInvalidMsg("need pass valid_data when nullable==true")
}
if len(validData) == 1 {
if !w.nullable {
return merr.WrapErrParameterInvalidMsg("no need pass valid_data when nullable==false")
}
isValid = validData[0]
}
return w.AddOneMolToPayload(val, isValid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This block of code for handling DataType_Mol is nearly identical to the existing case for DataType_Geometry. This duplication makes the code harder to maintain. Consider refactoring this shared logic into a helper function to reduce redundancy and improve readability.

Comment thread internal/storage/utils.go
Comment on lines +1046 to +1058
func mergeMolField(data *InsertData, fid FieldID, field *MolFieldData) {
if _, ok := data.Data[fid]; !ok {
fieldData := &MolFieldData{
Data: nil,
ValidData: nil,
Nullable: field.Nullable,
}
data.Data[fid] = fieldData
}
fieldData := data.Data[fid].(*MolFieldData)
fieldData.Data = append(fieldData.Data, field.Data...)
fieldData.ValidData = append(fieldData.ValidData, field.ValidData...)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The function mergeMolField is almost a direct copy of mergeJSONField. Since MolFieldData and JSONFieldData have the same structure, this is a great opportunity to use generics to create a single mergeBytePayloadField function. This would eliminate code duplication and make the system easier to extend with similar data types in the future.

@mergify

mergify Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

@862103595 go-sdk check failed, comment rerun go-sdk can trigger the job again.

@codecov

codecov Bot commented Jan 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.58050% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.96%. Comparing base (e70f045) to head (88c249a).
⚠️ Report is 984 commits behind head on master.

Files with missing lines Patch % Lines
internal/proxy/validate_util.go 76.53% 17 Missing and 6 partials ⚠️
pkg/util/typeutil/schema.go 86.04% 12 Missing ⚠️
internal/proxy/task_search.go 9.09% 8 Missing and 2 partials ⚠️
internal/storage/print_binlog.go 40.00% 6 Missing and 3 partials ⚠️
internal/proxy/task_query.go 0.00% 4 Missing and 1 partial ⚠️
internal/proxy/task.go 0.00% 2 Missing and 1 partial ⚠️
internal/storage/insert_data.go 96.00% 2 Missing and 1 partial ⚠️
internal/storage/payload_reader.go 83.33% 2 Missing and 1 partial ⚠️

❌ Your project check has failed because the head coverage (76.96%) is below the target coverage (77.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #46957      +/-   ##
==========================================
+ Coverage   74.36%   76.96%   +2.60%     
==========================================
  Files        1462     2064     +602     
  Lines      241270   338815   +97545     
==========================================
+ Hits       179423   260784   +81361     
- Misses      53637    69804   +16167     
- Partials     8210     8227      +17     
Components Coverage Δ
Client 78.58% <ø> (ø)
Core 83.38% <ø> (∅)
Go 75.25% <84.58%> (+0.02%) ⬆️
Files with missing lines Coverage Δ
internal/proxy/util.go 78.66% <100.00%> (-0.07%) ⬇️
internal/storage/data_codec.go 77.36% <100.00%> (+1.32%) ⬆️
internal/storage/data_sorter.go 85.34% <100.00%> (+0.38%) ⬆️
internal/storage/payload_writer.go 79.90% <100.00%> (+0.97%) ⬆️
internal/storage/serde.go 68.12% <100.00%> (+0.02%) ⬆️
internal/storage/utils.go 79.71% <100.00%> (+0.52%) ⬆️
pkg/common/common.go 44.96% <100.00%> (+1.23%) ⬆️
pkg/util/funcutil/func.go 70.63% <100.00%> (+0.21%) ⬆️
pkg/util/typeutil/gen_empty_field_data.go 5.66% <100.00%> (+5.66%) ⬆️
internal/proxy/task.go 77.82% <0.00%> (-0.26%) ⬇️
... and 7 more

... and 631 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from a6d0c0b to f6dbae9 Compare January 12, 2026 03:35
@mergify

mergify Bot commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

@862103595 go-sdk check failed, comment rerun go-sdk can trigger the job again.

@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from f6dbae9 to 4053377 Compare January 12, 2026 07:10
@mergify

mergify Bot commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

@862103595 Thanks for your contribution. Please submit with DCO, see the contributing guide https://github.com/milvus-io/milvus/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-dco.

@mergify mergify Bot added needs-dco DCO is missing in this pull request. and removed dco-passed DCO check passed. labels Jan 12, 2026
@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from 4053377 to cb9bd2a Compare January 12, 2026 07:17
@mergify

mergify Bot commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

@862103595 go-sdk check failed, comment rerun go-sdk can trigger the job again.

@sre-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 862103595
To complete the pull request process, please assign tedxu after the PR has been reviewed.
You can assign the PR to them by writing /assign @tedxu in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from 31d55d2 to b3b63e3 Compare January 15, 2026 08:44
@mergify

mergify Bot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

@862103595 go-sdk check failed, comment rerun go-sdk can trigger the job again.

@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from b3b63e3 to 598bca2 Compare January 15, 2026 12:20
@sre-ci-robot sre-ci-robot added the area/dependency Pull requests that update a dependency file label Jan 15, 2026
@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from 598bca2 to 3ebee18 Compare January 15, 2026 12:24
@sre-ci-robot sre-ci-robot added low-code-coverage add test-label from zhikun, diff coverage > 80% and removed low-code-coverage add test-label from zhikun, diff coverage > 80% labels Feb 10, 2026
@mergify mergify Bot added the ci-passed label Feb 10, 2026
@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from 759149c to b4bdc86 Compare February 10, 2026 07:32
@mergify

mergify Bot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

@862103595 Thanks for your contribution. Please submit with DCO, see the contributing guide https://github.com/milvus-io/milvus/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-dco.

@mergify mergify Bot added needs-dco DCO is missing in this pull request. and removed dco-passed DCO check passed. labels Feb 10, 2026
@sre-ci-robot sre-ci-robot removed the low-code-coverage add test-label from zhikun, diff coverage > 80% label Feb 10, 2026
@862103595
862103595 force-pushed the feat/mol-insert-implementation branch 2 times, most recently from e7648cd to 6f46cde Compare February 10, 2026 12:46
@mergify mergify Bot added dco-passed DCO check passed. and removed needs-dco DCO is missing in this pull request. labels Feb 10, 2026
@sre-ci-robot sre-ci-robot added low-code-coverage add test-label from zhikun, diff coverage > 80% and removed low-code-coverage add test-label from zhikun, diff coverage > 80% labels Feb 10, 2026
@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from 6f46cde to 02a2e66 Compare February 11, 2026 06:56
@862103595

Copy link
Copy Markdown
Contributor Author

rerun ut-cpp

@github-actions

Copy link
Copy Markdown
Contributor

Hello 862103595, you are not in the organization, so you do not have the permission to rerun the workflow, please contact @milvus-io/milvus-maintainers for help.

@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from 2d30cda to 06d3535 Compare February 11, 2026 08:18
@sre-ci-robot sre-ci-robot added low-code-coverage add test-label from zhikun, diff coverage > 80% and removed low-code-coverage add test-label from zhikun, diff coverage > 80% labels Feb 11, 2026
@mergify mergify Bot added the ci-passed label Feb 11, 2026
@862103595
862103595 force-pushed the feat/mol-insert-implementation branch from 06d3535 to 7974c46 Compare February 13, 2026 04:01
@mergify

mergify Bot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

@862103595 go-sdk check failed, comment rerun go-sdk can trigger the job again.

@xiaocai2333

Copy link
Copy Markdown
Contributor

rerun go-sdk

862103595 and others added 4 commits February 27, 2026 12:11
- Add MOL data type insert support with SMILES validation
- Implement SMILES↔Pickle conversion for storage and query return path
- Add FillWithNullValue and FillWithDefaultValue support for MOL type
- Sync milvus-proto for MOL data type definition
- Add unit tests with 80%+ coverage for MOL basic functionality

Signed-off-by: xiejh <862103595@qq.com>
Add genEmptyMolFieldData to handle empty MOL field data generation,
fixing "unsupported data type: Mol" error when query returns empty
results with MOL output fields.

Signed-off-by: xiejh <862103595@qq.com>
Remove stale milvus-proto version entries from go.sum and pkg/go.sum,
and fix go-commons-pool position in go.mod to match upstream.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: xiejh <862103595@qq.com>
Add tests for AppendFieldDataByColumn, GenEmptyFieldData, payload
writer/reader error paths, and print_binlog MOL branch to reach
80% patch coverage requirement.

Signed-off-by: xiejh <862103595@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dependency Pull requests that update a dependency file dco-passed DCO check passed. do-not-merge/missing-design-doc kind/feature Issues related to feature request from users size/XXL Denotes a PR that changes 1000+ lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants