-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[GH-3609]: Add new sort order for int96 timestamps #3610
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
base: master
Are you sure you want to change the base?
Changes from all commits
c186f73
cd8062a
cc274c3
35a6036
6ee32f5
41d1b37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,7 @@ | |
| import org.apache.parquet.format.GeometryType; | ||
| import org.apache.parquet.format.GeospatialStatistics; | ||
| import org.apache.parquet.format.IEEE754TotalOrder; | ||
| import org.apache.parquet.format.Int96TimestampOrder; | ||
| import org.apache.parquet.format.IntType; | ||
| import org.apache.parquet.format.KeyValue; | ||
| import org.apache.parquet.format.LogicalType; | ||
|
|
@@ -146,6 +147,7 @@ public class ParquetMetadataConverter { | |
|
|
||
| private static final TypeDefinedOrder TYPE_DEFINED_ORDER = new TypeDefinedOrder(); | ||
| private static final IEEE754TotalOrder IEEE_754_TOTAL_ORDER = new IEEE754TotalOrder(); | ||
| private static final Int96TimestampOrder INT96_TIMESTAMP_ORDER = new Int96TimestampOrder(); | ||
| public static final MetadataFilter NO_FILTER = new NoFilter(); | ||
| public static final MetadataFilter SKIP_ROW_GROUPS = new SkipMetadataFilter(); | ||
| public static final long MAX_STATS_SIZE = 4096; // limit stats to 4k | ||
|
|
@@ -290,6 +292,9 @@ private List<ColumnOrder> getColumnOrders(MessageType schema) { | |
| case IEEE_754_TOTAL_ORDER: | ||
| columnOrder.setIEEE_754_TOTAL_ORDER(IEEE_754_TOTAL_ORDER); | ||
| break; | ||
| case INT96_TIMESTAMP_ORDER: | ||
| columnOrder.setINT96_TIMESTAMP_ORDER(INT96_TIMESTAMP_ORDER); | ||
| break; | ||
| case UNDEFINED: | ||
| // Use TypeDefinedOrder if some types (e.g. INT96) have undefined column orders. | ||
| columnOrder.setTYPE_ORDER(TYPE_DEFINED_ORDER); | ||
|
|
@@ -911,8 +916,16 @@ private static byte[] tuncateMax(BinaryTruncator truncator, int truncateLength, | |
| } | ||
|
|
||
| private static boolean isMinMaxStatsSupported(PrimitiveType type) { | ||
| return type.columnOrder().getColumnOrderName() == ColumnOrderName.TYPE_DEFINED_ORDER | ||
| || type.columnOrder().getColumnOrderName() == ColumnOrderName.IEEE_754_TOTAL_ORDER; | ||
| switch (type.columnOrder().getColumnOrderName()) { | ||
| case TYPE_DEFINED_ORDER: | ||
| case IEEE_754_TOTAL_ORDER: | ||
| case INT96_TIMESTAMP_ORDER: | ||
| return true; | ||
| case UNDEFINED: | ||
| return false; | ||
| default: | ||
| throw new IllegalArgumentException("Unknown column order: " + type.columnOrder()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think we would normal throw
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer to leave |
||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -2057,7 +2070,17 @@ private void buildChildren( | |
| || schemaElement.converted_type == ConvertedType.INTERVAL)) { | ||
| columnOrder = org.apache.parquet.schema.ColumnOrder.undefined(); | ||
| } | ||
| // INT96_TIMESTAMP_ORDER is only valid for INT96 columns, ignore it anywhere else. | ||
| if (columnOrder.getColumnOrderName() == ColumnOrderName.INT96_TIMESTAMP_ORDER | ||
| && schemaElement.type != Type.INT96) { | ||
| columnOrder = org.apache.parquet.schema.ColumnOrder.undefined(); | ||
| } | ||
| primitiveBuilder.columnOrder(columnOrder); | ||
| } else if (schemaElement.type == Type.INT96) { | ||
| // A footer without column orders predates INT96_TIMESTAMP_ORDER, so an INT96 column here | ||
| // must not inherit the (chronological) construction-time default: its stats, if any, were | ||
| // written under the legacy order and must be ignored. | ||
| primitiveBuilder.columnOrder(org.apache.parquet.schema.ColumnOrder.undefined()); | ||
|
divjotarora marked this conversation as resolved.
|
||
| } | ||
| childBuilder = primitiveBuilder; | ||
| } else { | ||
|
|
@@ -2110,6 +2133,9 @@ private static org.apache.parquet.schema.ColumnOrder fromParquetColumnOrder(Colu | |
| if (columnOrder.isSetIEEE_754_TOTAL_ORDER()) { | ||
| return org.apache.parquet.schema.ColumnOrder.ieee754TotalOrder(); | ||
| } | ||
| if (columnOrder.isSetINT96_TIMESTAMP_ORDER()) { | ||
| return org.apache.parquet.schema.ColumnOrder.int96TimestampOrder(); | ||
| } | ||
| // The column order is not yet supported by this API | ||
| return org.apache.parquet.schema.ColumnOrder.undefined(); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.