-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Uptading the implementation of ArrowRegistry and ParquetField class #19562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
darjisagar7
wants to merge
3
commits into
opensearch-project:feature/datafusion
Choose a base branch
from
darjisagar7:feature/datafusion
base: feature/datafusion
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,155
−126
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"rustc_fingerprint":11842151147061415538,"outputs":{"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.89.0 (29483883e 2025-08-04)\nbinary: rustc\ncommit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2\ncommit-date: 2025-08-04\nhost: aarch64-apple-darwin\nrelease: 1.89.0\nLLVM version: 20.1.7\n","stderr":""},"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/darsaga/.rustup/toolchains/stable-aarch64-apple-darwin\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"aes\"\ntarget_feature=\"crc\"\ntarget_feature=\"dit\"\ntarget_feature=\"dotprod\"\ntarget_feature=\"dpb\"\ntarget_feature=\"dpb2\"\ntarget_feature=\"fcma\"\ntarget_feature=\"fhm\"\ntarget_feature=\"flagm\"\ntarget_feature=\"fp16\"\ntarget_feature=\"frintts\"\ntarget_feature=\"jsconv\"\ntarget_feature=\"lor\"\ntarget_feature=\"lse\"\ntarget_feature=\"neon\"\ntarget_feature=\"paca\"\ntarget_feature=\"pacg\"\ntarget_feature=\"pan\"\ntarget_feature=\"pmuv3\"\ntarget_feature=\"ras\"\ntarget_feature=\"rcpc\"\ntarget_feature=\"rcpc2\"\ntarget_feature=\"rdm\"\ntarget_feature=\"sb\"\ntarget_feature=\"sha2\"\ntarget_feature=\"sha3\"\ntarget_feature=\"ssbs\"\ntarget_feature=\"vh\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""}},"successes":{}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Signature: 8a477f597d28d172789f06886806bc55 | ||
# This file is a cache directory tag created by cargo. | ||
# For information about cache directory tags see https://bford.info/cachedir/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...et-data-format/src/main/java/com/parquet/parquetdataformat/fields/ArrowSchemaBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package com.parquet.parquetdataformat.fields; | ||
|
||
import org.apache.arrow.vector.types.pojo.Field; | ||
import org.apache.arrow.vector.types.pojo.Schema; | ||
import org.opensearch.index.mapper.Mapper; | ||
import org.opensearch.index.mapper.MapperService; | ||
import org.opensearch.index.mapper.MetadataFieldMapper; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Utility class for creating Apache Arrow schemas from OpenSearch mapper services. | ||
* This class provides methods to convert OpenSearch field mappings into Arrow schema definitions | ||
* that can be used for Parquet data format operations. | ||
*/ | ||
public final class ArrowSchemaBuilder { | ||
|
||
// Private constructor to prevent instantiation of utility class | ||
private ArrowSchemaBuilder() { | ||
throw new UnsupportedOperationException("Utility class should not be instantiated"); | ||
} | ||
|
||
/** | ||
* Creates an Apache Arrow Schema from the provided MapperService. | ||
* This method extracts all non-metadata field mappers and converts them to Arrow fields. | ||
* | ||
* @param mapperService the OpenSearch mapper service containing field definitions | ||
* @return a new Schema containing Arrow field definitions for all mapped fields | ||
* @throws IllegalArgumentException if mapperService is null | ||
* @throws IllegalStateException if no valid fields are found or if a field type is not supported | ||
*/ | ||
public static Schema getSchema(final MapperService mapperService) { | ||
Objects.requireNonNull(mapperService, "MapperService cannot be null"); | ||
|
||
final List<Field> fields = extractFieldsFromMappers(mapperService); | ||
|
||
if (fields.isEmpty()) { | ||
throw new IllegalStateException("No valid fields found in mapper service"); | ||
} | ||
|
||
return new Schema(fields); | ||
} | ||
|
||
/** | ||
* Extracts Arrow fields from the mapper service, filtering out metadata fields. | ||
* | ||
* @param mapperService the mapper service to extract fields from | ||
* @return a list of Arrow fields | ||
*/ | ||
private static List<Field> extractFieldsFromMappers(final MapperService mapperService) { | ||
final List<Field> fields = new ArrayList<>(); | ||
|
||
for (final Mapper mapper : mapperService.documentMapper().mappers()) { | ||
if (isMetadataField(mapper)) { | ||
continue; | ||
} | ||
|
||
final Field arrowField = createArrowField(mapper); | ||
fields.add(arrowField); | ||
} | ||
|
||
return fields; | ||
} | ||
|
||
/** | ||
* Checks if the given mapper represents a metadata field. | ||
* | ||
* @param mapper the mapper to check | ||
* @return true if the mapper is a metadata field, false otherwise | ||
*/ | ||
private static boolean isMetadataField(final Mapper mapper) { | ||
return mapper instanceof MetadataFieldMapper; | ||
} | ||
|
||
/** | ||
* Creates an Arrow Field from an OpenSearch Mapper. | ||
* | ||
* @param mapper the mapper to convert | ||
* @return a new Arrow Field | ||
* @throws IllegalStateException if the mapper type is not supported | ||
*/ | ||
private static Field createArrowField(final Mapper mapper) { | ||
final ParquetField parquetField = ArrowFieldRegistry.getParquetField(mapper.typeName()); | ||
|
||
if (parquetField == null) { | ||
throw new IllegalStateException( | ||
String.format("Unsupported field type '%s' for field '%s'", | ||
mapper.typeName(), mapper.name()) | ||
); | ||
} | ||
|
||
return new Field(mapper.name(), parquetField.getFieldType(), null); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Let's add these files to gitignore. I think we can add parquet-data-format/jni/target/*.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed