Skip to content

Commits data fusion - #273

Merged
sandeshkr419 merged 114 commits into
dffrom
feature/datafusion
Dec 1, 2025
Merged

Commits data fusion#273
sandeshkr419 merged 114 commits into
dffrom
feature/datafusion

Conversation

@sandeshkr419

Copy link
Copy Markdown
Owner

Description

[Describe what this change achieves]

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

mch2 and others added 30 commits November 4, 2025 10:20
Signed-off-by: Marc Handalian <marc.handalian@gmail.com>
(cherry picked from commit cb75910)
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
(cherry picked from commit eb01905)
…project#19399)

Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
(cherry picked from commit c9d5b17)
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
(cherry picked from commit 98de93e)
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
(cherry picked from commit 5fef617)
Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
(cherry picked from commit e4ebf59)
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Co-authored-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Co-authored-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
* Abstracting lucene away: part 1

* initial abstractions to reduce indexing engine coupling

* Text backed engine testing

---------

Co-authored-by: Mohit Godwani <mgodwan@amazon.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
* Changes in dataformat for CSVEngine

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>

* Changes for Reader to work

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>

---------

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
Co-authored-by: Bharathwaj G <bharath78910@gmail.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
* Integrate aggregators to convert result from datafusion

Signed-off-by: expani <anijainc@amazon.com>

* Initialised bigArrays and queryCollManagers for DatafusionContext

Signed-off-by: expani <anijainc@amazon.com>

* Refactored to set agg result within utility

Signed-off-by: expani <anijainc@amazon.com>

---------

Signed-off-by: expani <anijainc@amazon.com>
Co-authored-by: Arpit Bandejiya <abandeji@amazon.com>

Signed-off-by: bharath-techie <bharath78910@gmail.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
Signed-off-by: bharath-techie <bharath78910@gmail.com>
* Feature/datafusion 4 (#46)

* Composite document writer pool initial implementation

* Committer interface and lucene based commit engine implementation

* Catalog snapshot changes to create segment view during commit

---------

Co-authored-by: Shashank Gowri <shnkgo@amazon.com>

* fix build for commit integration

Signed-off-by: bharath-techie <bharath78910@gmail.com>

---------

Signed-off-by: bharath-techie <bharath78910@gmail.com>
Co-authored-by: Shashank Gowri <shnkgo@amazon.com>
expani and others added 26 commits November 17, 2025 13:07
* Add parquet benchmarks in missing javadoc

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>

* add flag to disable java doc check

---------

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
* Single commit with all changes

* Update the e2e test workflow

* Ignore lint

* Add missing doc flag

* fix newline

* remove extra missingdoc flag in action

* Add changes to have all queries

* Run only DatafusionReaderManager test

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>

* Fix 200 status code

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>

---------

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
* Add CacheManager

# Conflicts:
#	plugins/engine-datafusion/jni/src/lib.rs
#	plugins/engine-datafusion/jni/src/listing_table.rs
#	plugins/engine-datafusion/jni/src/row_id_optimizer.rs
#	plugins/engine-datafusion/jni/src/util.rs

# Conflicts:
#	plugins/engine-datafusion/jni/src/lib.rs
#	plugins/engine-datafusion/src/main/java/org/opensearch/datafusion/DataFusionQueryJNI.java
#	plugins/engine-datafusion/src/main/java/org/opensearch/datafusion/DataFusionService.java
#	plugins/engine-datafusion/src/main/java/org/opensearch/datafusion/core/GlobalRuntimeEnv.java
#	plugins/engine-datafusion/src/main/java/org/opensearch/datafusion/search/DatafusionSearcher.java
#	plugins/engine-datafusion/src/test/java/org/opensearch/datafusion/DataFusionReaderManagerTests.java

# Conflicts:
#	plugins/engine-datafusion/jni/src/lib.rs
#	plugins/engine-datafusion/src/main/java/org/opensearch/datafusion/DataFusionPlugin.java
#	plugins/engine-datafusion/src/main/java/org/opensearch/datafusion/DataFusionService.java
#	plugins/engine-datafusion/src/main/java/org/opensearch/datafusion/core/GlobalRuntimeEnv.java
#	plugins/engine-datafusion/src/main/java/org/opensearch/datafusion/search/DatafusionSearcher.java
#	plugins/engine-datafusion/src/test/java/org/opensearch/datafusion/DataFusionReaderManagerTests.java
#	plugins/engine-datafusion/src/test/java/org/opensearch/datafusion/DataFusionServiceTests.java
#	plugins/engine-datafusion/src/test/java/org/opensearch/datafusion/TestDataFusionServiceTests.java

* create CacheManager struct

* rebase

* add file2

* fix references

* cleanup commented code

* remove unused references

* rebase1

* Add Native Handles

* moving cacheOperations to use runtimeEnv

* fix references

* runtimeHandle reference

* rename configPtr reference
…#20048)

* add stream and allocator closure post fetch phase

Signed-off-by: Marc Handalian <marc.handalian@gmail.com>

* Move stream and allocator for executeQueryPhase into correct scope

Signed-off-by: Marc Handalian <marc.handalian@gmail.com>

---------

Signed-off-by: Marc Handalian <marc.handalian@gmail.com>
…nsearch-project#20032)

* Injecting count sub agg if absent to ensure doc_count is correct

Signed-off-by: expani <anijainc@amazon.com>

* Sorting keys for merge sort to work

Signed-off-by: expani <anijainc@amazon.com>

* Went into zen mode and made code simpler

Signed-off-by: expani <anijainc@amazon.com>

---------

Signed-off-by: expani <anijainc@amazon.com>
…ject#20041)

* Single commit with all changes

* Update the e2e test workflow

* Clean unused functions

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>

* remove imports

---------

Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
Signed-off-by: Dhwanil Patel <dhwanip@amazon.com>
* fixing path reference while adding to cache

* remove unnecessary logs
…s with Searcher (opensearch-project#20063)

* CatalogSnapshot Manager + postDelete hooks

* Fix tests

* Minor fixes to post delete hooks

* Fix IndexFileDeleterTests

* Add IndexFileDeleter tests in E2E

* Empty commit to re-run E2E tests
Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
…project#20079)

These tests run 42 or 43 queries right now and match results for correctness.
all queries flagged as supported are expected to succeed for this check to pass

Signed-off-by: Marc Handalian <marc.handalian@gmail.com>
Signed-off-by: Marc Handalian <marc.handalian@gmail.com>
…sync changes (opensearch-project#20071)

* Changes for tokio io/cpu runtime + search flow async changes

Signed-off-by: bharath-techie <bharath78910@gmail.com>

* minor fixes and todos

Signed-off-by: bharath-techie <bharath78910@gmail.com>

* Addressing comment to move to ActionListener

Signed-off-by: bharath-techie <bharath78910@gmail.com>

* addressing comments

Signed-off-by: bharath-techie <bharath78910@gmail.com>

* fix to sort numeric aggs

Signed-off-by: bharath-techie <bharath78910@gmail.com>

---------

Signed-off-by: bharath-techie <bharath78910@gmail.com>
…pensearch-project#19978)

* Adding JNI abstractions for logging in rust through RustLoggerBridge

Signed-off-by: Raghuvansh Raj <raghraaj@amazon.com>

* Adding logging for java in parquet-data-format module and cleaning up stale files

Signed-off-by: Raghuvansh Raj <raghraaj@amazon.com>

---------

Signed-off-by: Raghuvansh Raj <raghraaj@amazon.com>
* Refactor stream handling for DF execution

* Change to Buffer Allocator for DF execution

* Introduce RecordBatchIterator and integrate with collector

* Minor fixup

* Update VSRManager to update field vector atomically

* Fixup

* Fixup

* Fixup

* Test fixup

* Integrate with AsyncRecordBatchIterator

* Fix up
* Update MetadataCache Warm-up to include page-indexes

* disable dynamic metadtaa cache limit updates
* Add tests for NativeParquetWriter

* Run Rust UTs in E2E tests
* No-op load writer files implementation

* Implemented flush conditions and improved engine failure handling

---------

Co-authored-by: Shashank Gowri <shnkgo@amazon.com>
@sandeshkr419
sandeshkr419 merged commit 92bb76f into df Dec 1, 2025
4 checks passed
@sandeshkr419
sandeshkr419 deleted the feature/datafusion branch December 1, 2025 21:31
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @sandeshkr419, 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 introduces significant architectural enhancements to OpenSearch by integrating the DataFusion query engine and enabling native Parquet data format support. The changes involve creating new plugins for Parquet data handling and DataFusion integration, along with a dedicated module for vectorized execution interfaces. This foundational work sets the stage for high-performance, columnar data processing within OpenSearch, leveraging Rust for native code execution and Apache Arrow for efficient in-memory data representation. The build system has been updated to seamlessly manage these new multi-language components, and JVM configurations are adjusted to optimize memory usage for vectorized operations.

Highlights

  • New Parquet Data Format Plugin: Introduced a new plugin, modules/parquet-data-format, to enable OpenSearch to store and index data in the columnar Parquet format. This plugin leverages JNI bindings to a high-performance Rust backend for efficient Parquet file generation and management.
  • New DataFusion Engine Plugin: Added a new plugin, plugins/engine-datafusion, which integrates the DataFusion query engine with OpenSearch. This integration enables vectorized query execution, significantly enhancing analytical capabilities and performance by processing data in a columnar fashion.
  • Vectorized Execution Service Provider Interface (SPI): A new module, libs/vectorized-exec-spi, was created to define common interfaces for vectorized execution. This includes standardized JNI native handle management and a flexible SPI for different data formats, ensuring extensibility and interoperability.
  • Enhanced Build System for Rust and Java Integration: Updated various Gradle files (.gitattributes, .gitignore, gradle/missing-javadoc.gradle, gradle/run.gradle) to support the new Rust-based components and native library handling. This includes configuring Rust build processes, managing generated files, and streamlining the integration of Java and native code.
  • Optimized JVM and DataFusion Configuration: Modified distribution/src/config/jvm.options and distribution/src/config/opensearch.yml to include settings for native memory tracking, diagnostic VM options, Arrow allocator debugging, and configurable DataFusion memory pool limits, allowing for fine-tuned performance and resource management.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/datafusion-e2e-test.yml
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.

@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 a significant amount of new code for Data Fusion integration, including new modules for Parquet data format and a DataFusion engine plugin. The changes span across Java, Gradle, and Rust. While this is a substantial feature addition, the review has identified several critical and high-severity issues that must be addressed. These include a security vulnerability related to arbitrary code execution in a Gradle script, incorrect logic in core components, disabled API validation checks, and the use of temporary debugging flags that disable assertions. There are also a number of medium-severity issues concerning code quality, maintainability, and potential bugs. The pull request appears to be in an early stage of development and requires thorough review and fixes before it can be considered for merging.

cluster.setPreserveDataDir(preserveData);
for (OpenSearchNode node : cluster.getNodes()) {
// TODO : remove this - this disables assertions
node.jvmArgs(" -da ");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The JVM argument -da disables assertions. The accompanying TODO comment suggests this is a temporary debugging measure. Merging this change would disable important safety checks in tests, potentially hiding bugs. This line must be removed before this pull request is merged.

}

public DataFormat getDataFormat() {
return DataFormat.CSV;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

This ParquetDataSourceCodec incorrectly returns DataFormat.CSV. It should return DataFormat.PARQUET.

Suggested change
return DataFormat.CSV;
return DataFormat.PARQUET;

Comment on lines +50 to +57
public boolean equals(Object obj) {
return true;
}

@Override
public int hashCode() {
return 0;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The equals() method always returns true, and hashCode() always returns 0. This violates the Java object contract and can lead to incorrect behavior in collections like HashMap or HashSet. Since this class appears to be stateless, it could be implemented as a singleton, or equals() should perform a proper type check.

Suggested change
public boolean equals(Object obj) {
return true;
}
@Override
public int hashCode() {
return 0;
}
public boolean equals(Object obj) {
return obj instanceof ParquetDataFormat;
}
@Override
public int hashCode() {
return getClass().hashCode();
}

Comment thread gradle/run.gradle
}

if (findProperty("remotePlugins")) {
remotePlugins = Eval.me(remotePlugins)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The use of Eval.me(remotePlugins) introduces a critical security vulnerability. It allows for arbitrary code execution, as a malicious user could provide a crafted string to the remotePlugins property. This should be replaced with a safer parsing mechanism, such as splitting the string by a delimiter.

      def remotePluginsList = remotePlugins.split(',').collect { it.trim() }

Comment on lines +88 to +101
// for (var element : elements) {
// validate(element);
//
// if (!checkPackage(element)) {
// continue;
// }
//
// // Skip all not-public elements
// checkPublicVisibility(null, element);
//
// if (element instanceof TypeElement) {
// process((TypeElement) element);
// }
// }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The core logic of the process method has been commented out, which effectively disables the ApiAnnotationProcessor. This processor is crucial for validating API annotations like @PublicApi and @ExperimentalApi. Disabling it compromises API contract enforcement and should be reverted.

Comment on lines +27 to +29
// Note: MutexFileMetadataCache wrapper has been removed as DefaultFilesMetadataCache
// is already thread-safe with its own internal Mutex.
// The double-locking was causing race conditions and crashes.

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 comment states that MutexFileMetadataCache has been removed, but the struct is defined immediately after. The comment is outdated and should be removed or updated to avoid confusion.


TOKIO_RUNTIME_MANAGER.get_or_init(|| {
println!("Runtime manager initialized with {} CPU threads", cpu_threads);
Arc::new(RuntimeManager::new(cpu_threads as usize))

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

Using println! for logging is not ideal. It's better to use the log crate, which is already a dependency. This allows for structured logging with configurable levels and can be routed to the Java logging framework.

Suggested change
Arc::new(RuntimeManager::new(cpu_threads as usize))
info!("Runtime manager initialized with {} CPU threads", cpu_threads);

if cache_guard.contains_key(object_meta) {
Ok(true)
} else {
println!("[CACHE ERROR] Failed to cache metadata for: {}", file_path);

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

Using println! for error logging is not ideal. It's better to use the log crate (e.g., log::error!) for structured logging, which will provide better visibility and control over log output.

Suggested change
println!("[CACHE ERROR] Failed to cache metadata for: {}", file_path);
log::error!("[CACHE ERROR] Failed to cache metadata for: {}", file_path);

Comment on lines +184 to +187

return settingList;
}

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 use of streams to collect settings here is unnecessarily complex. This can be simplified by directly adding the setting lists to settingList, which would improve readability.

Suggested change
return settingList;
}
settingList.addAll(CacheSettings.CACHE_SETTINGS);
settingList.addAll(CacheSettings.CACHE_ENABLED);

type.getEvictionType(clusterSettings));

NativeBridge.createCache(cacheManagerPtr, type.cacheTypeName, type.getSizeLimit(clusterSettings).getBytes(), type.getEvictionType(clusterSettings));
// clusterSettings.addSettingsUpdateConsumer(type.sizeLimitSetting,(v) -> NativeBridge.cacheManagerUpdateSizeLimitForCacheType(cacheManagerPtr, CacheType.METADATA.getCacheTypeName(),v.getBytes()));

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 line is commented out. It appears to be intended for dynamically updating cache size limits. It should either be implemented to enable this functionality or removed to keep the code clean.

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.