[jira] [Commented] (PARQUET-1344) Type builders don't honor new logical types

2018-07-04 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/PARQUET-1344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16532654#comment-16532654
 ] 

ASF GitHub Bot commented on PARQUET-1344:
-

gszadovszky closed pull request #500: PARQUET-1344: Type builders don't honor 
new logical types
URL: https://github.com/apache/parquet-mr/pull/500
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/parquet-column/src/main/java/org/apache/parquet/schema/Types.java 
b/parquet-column/src/main/java/org/apache/parquet/schema/Types.java
index 54fb1d885..165a5acea 100644
--- a/parquet-column/src/main/java/org/apache/parquet/schema/Types.java
+++ b/parquet-column/src/main/java/org/apache/parquet/schema/Types.java
@@ -514,7 +514,11 @@ protected PrimitiveType build(String name) {
 }
   }
 
-  return new PrimitiveType(repetition, primitiveType, length, name, 
getOriginalType(), meta, id, columnOrder);
+  if (newLogicalTypeSet) {
+return new PrimitiveType(repetition, primitiveType, length, name, 
logicalTypeAnnotation, id, columnOrder);
+  } else {
+return new PrimitiveType(repetition, primitiveType, length, name, 
getOriginalType(), meta, id, columnOrder);
+  }
 }
 
 private static long maxPrecision(int numBytes) {
@@ -702,7 +706,11 @@ public THIS addFields(Type... types) {
 
 @Override
 protected GroupType build(String name) {
-  return new GroupType(repetition, name, getOriginalType(), fields, id);
+  if (newLogicalTypeSet) {
+return new GroupType(repetition, name, logicalTypeAnnotation, fields, 
id);
+  } else {
+return new GroupType(repetition, name, getOriginalType(), fields, id);
+  }
 }
 
 public MapBuilder map(
diff --git 
a/parquet-column/src/test/java/org/apache/parquet/schema/TestTypeBuilders.java 
b/parquet-column/src/test/java/org/apache/parquet/schema/TestTypeBuilders.java
index a42e9e33b..82e58ef7d 100644
--- 
a/parquet-column/src/test/java/org/apache/parquet/schema/TestTypeBuilders.java
+++ 
b/parquet-column/src/test/java/org/apache/parquet/schema/TestTypeBuilders.java
@@ -26,6 +26,9 @@
 import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName;
 import org.apache.parquet.schema.Type.Repetition;
 
+import static org.apache.parquet.schema.LogicalTypeAnnotation.TimeUnit.MICROS;
+import static org.apache.parquet.schema.LogicalTypeAnnotation.TimeUnit.MILLIS;
+import static org.apache.parquet.schema.LogicalTypeAnnotation.timestampType;
 import static org.apache.parquet.schema.OriginalType.*;
 import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.*;
 import static org.apache.parquet.schema.Type.Repetition.*;
@@ -1423,6 +1426,32 @@ public void 
testDecimalLogicalTypeWithDeprecatedPrecision() {
 Assert.assertEquals(expected, actual);
   }
 
+  @Test
+  public void testTimestampLogicalTypeWithUTCParameter() {
+PrimitiveType utcMillisExpected = new PrimitiveType(REQUIRED, INT64, 
"aTimestamp",
+  timestampType(true, MILLIS));
+PrimitiveType nonUtcMillisExpected = new PrimitiveType(REQUIRED, INT64, 
"aTimestamp",
+  timestampType(false, MILLIS));
+PrimitiveType utcMicrosExpected = new PrimitiveType(REQUIRED, INT64, 
"aTimestamp",
+  timestampType(true, MICROS));
+PrimitiveType nonUtcMicrosExpected = new PrimitiveType(REQUIRED, INT64, 
"aTimestamp",
+  timestampType(false, MICROS));
+
+PrimitiveType utcMillisActual = Types.required(INT64)
+  .as(timestampType(true, MILLIS)).named("aTimestamp");
+PrimitiveType nonUtcMillisActual = Types.required(INT64)
+  .as(timestampType(false, MILLIS)).named("aTimestamp");
+PrimitiveType utcMicrosActual = Types.required(INT64)
+  .as(timestampType(true, MICROS)).named("aTimestamp");
+PrimitiveType nonUtcMicrosActual = Types.required(INT64)
+  .as(timestampType(false, MICROS)).named("aTimestamp");
+
+Assert.assertEquals(utcMillisExpected, utcMillisActual);
+Assert.assertEquals(nonUtcMillisExpected, nonUtcMillisActual);
+Assert.assertEquals(utcMicrosExpected, utcMicrosActual);
+Assert.assertEquals(nonUtcMicrosExpected, nonUtcMicrosActual);
+  }
+
   @Test(expected = IllegalArgumentException.class)
   public void testDecimalLogicalTypeWithDeprecatedScaleMismatch() {
 Types.required(BINARY)


 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Type builders don't honor new logical types
> 

[jira] [Commented] (PARQUET-1344) Type builders don't honor new logical types

2018-06-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/PARQUET-1344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16527955#comment-16527955
 ] 

ASF GitHub Bot commented on PARQUET-1344:
-

nandorKollar opened a new pull request #500: PARQUET-1344: Type builders don't 
honor new logical types
URL: https://github.com/apache/parquet-mr/pull/500
 
 
   Call propert constructor when builder is caller with new logical type,
   call the deprecated OriginalType version otherwise.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Type builders don't honor new logical types
> ---
>
> Key: PARQUET-1344
> URL: https://issues.apache.org/jira/browse/PARQUET-1344
> Project: Parquet
>  Issue Type: Bug
>  Components: parquet-mr
>Reporter: Nandor Kollar
>Assignee: Nandor Kollar
>Priority: Major
>  Labels: pull-request-available
>
> Type builder still use OriginalType constructors even for new logical types. 
> Therefore one can't build a timestamp type with UTC adjustment = false with 
> the type builder, because they default utc adjustment to false (via 
> OriginalType conversion)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)