Comments (4)
Hi @bmacphee,
You are correct. The row oriented API makes too many trade-offs between ease of use, flexibility and performance. It's there to make it easy for new starters to read a Parquet file, but not heavily encouraged.
Nonethless, the feature you might be looking for is the addition of a C# field attribute to explictly state that a tuple field maps to a particular column name. For example:
struct MyTuple
{
[MapToColumnName("Index")]
int Item1;
[MapToColumnName("Value")]
float Item2;
}
Orthogonally one can imagine a ColumnOrder(int)
attribute to reflect the current implicit column ordering and make it explicit. Things get messy when you start mixing things together (i.e. how much flexibility do you allow?).
Perhaps as a first start, if MapToColumnName
is used, then all columns need to be marked with this attribute (and throw an exception if not). I'd suggest looking at GetFieldsAndProperties()
in RowOriented/ParquetFile.cs and working up from there. Afterall, the introduction of such a field attribute would only change the ordering of the resulting array.
Edit: I cannot decide whether it should be called ColumnName
or MapToColumnName
. The former describe an explicit column name, while the latter hints at a different ordering when reading.
from parquetsharp.
I've also noticed that GetFieldsAndProperties()
has little ordering guarantees if you start mixing fields and properties, as they are listed by type (fields first, properties second).
from parquetsharp.
I did consider using attributes as a way to expose this to potential users without having to have a mode toggle argument or something. My initial proof of concept just did it by relying on what's returned from GetFieldsAndProperties
being exact matches (case sensitive) for the parquet file, which was totally fine for my purposes.
I agree it would make sense to enforce the all-or-nothing approach with the column names, even if the attributes just end up echoing the field names. It's still convenient enough as you only need to write the data class once.
I don't have a diff to show right this second but what I did was add this to the ParquetRowReader construction:
// TODO: validate types?
// TODO: conditions for handling bare tuples for TTuple type?
Dictionary<string, int> fileColumnIndexes = new Dictionary<string, int>();
for (int i = 0; i < _parquetFileReader.FileMetaData.Schema.NumColumns; ++i)
{
fileColumnIndexes[_parquetFileReader.FileMetaData.Schema.Column(i).Name] = i;
}
for (int i = 0; i < fields.Length; ++i)
{
_objectToFileColumnMapping[i] = fileColumnIndexes[fields[i].name];
}
and then ReadColumn
just looks up the "correct" column when asked by changing the index.
I appreciate the input.
from parquetsharp.
Merging into master as part of PR #108.
from parquetsharp.
Related Issues (20)
- CI build fails on master HOT 3
- Release ParquetSharp 8.0.0-beta2
- Upgrade to Arrow 9.0.0
- [CI] Fix deprecation warnings HOT 13
- ManagedRandomAccessFile: A callback was made on a garbage collected delegate HOT 4
- Exception when loading decimal (10,4) column HOT 6
- Cannot decrypt files with pyarrow HOT 2
- Access PageIndex HOT 2
- [Read] Read Decimal LogicalType HOT 5
- RowOriented API fails silently when using internal types in F# HOT 2
- [DOC] How to write nested data struct HOT 1
- Clarify nesting example "objects" status HOT 1
- Managing size of MemoryStream HOT 3
- [ARROW] Add Arrow RecordBatch Reader/Writer HOT 5
- Allow logical type override for decimal when logical system type (c# type) is not decimal HOT 2
- Is SIMD automatically supported in ParquetSharp HOT 2
- System.DllNotFoundException: Unable to load DLL 'ParquetSharpNative' HOT 7
- How to turn off nullable operation for int double? HOT 1
- Upgrade to Arrow 12.0.1 HOT 3
- Question: Is there a way to write to a partitioned directory HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parquetsharp.