You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/08/13 22:33:38 UTC

[GitHub] [iceberg] edgarRd opened a new pull request #1339: ORC: Use MetricsConfig for ORC metrics

edgarRd opened a new pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339


   Unlike Parquet metrics, ORC was not using `MetricsConfig` to let the user configure which metrics to collect or truncate string column metrics.
   
   This PR fixes #1268 by adding `MetricsConfig` support in ORC metrics. I've also added unit tests to `TestMetrics`, which runs for both Parquet and ORC, to check the different `MetricsModes` and the truncation of string and binary (not supported in ORC) columns.
   
   PTAL @aokolnychyi @rdsr @shardulm94 Thanks!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] edgarRd commented on pull request #1339: ORC: Use MetricsConfig

Posted by GitBox <gi...@apache.org>.
edgarRd commented on pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339#issuecomment-675102013


   Friendly ping in this PR: @aokolnychyi @rdsr @rdblue Thanks!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] shardulm94 commented on a change in pull request #1339: ORC: Use MetricsConfig

Posted by GitBox <gi...@apache.org>.
shardulm94 commented on a change in pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339#discussion_r472815623



##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcMetrics.java
##########
@@ -203,7 +227,29 @@ private static Metrics buildOrcMetrics(final long numOfRows, final TypeDescripti
       BooleanColumnStatistics booleanStats = (BooleanColumnStatistics) columnStats;
       max = booleanStats.getTrueCount() > 0;
     }
-    return Optional.ofNullable(Conversions.toByteBuffer(column.type(), max));
+    return Optional.ofNullable(Conversions.toByteBuffer(type, truncateIfNeeded(Bound.UPPER, type, max, metricsMode)));
+  }
+
+  private static Object truncateIfNeeded(Bound bound, Type type, Object value, MetricsMode metricsMode) {
+    // ORC only stores min/max for String columns

Review comment:
       Got confused for a second, I think what the comment wants to say is that out of the two types which require truncation (string/binary) ORC only supports string bounds. Can we rephrase the comment?

##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcMetrics.java
##########
@@ -203,7 +227,29 @@ private static Metrics buildOrcMetrics(final long numOfRows, final TypeDescripti
       BooleanColumnStatistics booleanStats = (BooleanColumnStatistics) columnStats;
       max = booleanStats.getTrueCount() > 0;
     }
-    return Optional.ofNullable(Conversions.toByteBuffer(column.type(), max));
+    return Optional.ofNullable(Conversions.toByteBuffer(type, truncateIfNeeded(Bound.UPPER, type, max, metricsMode)));
+  }
+
+  private static Object truncateIfNeeded(Bound bound, Type type, Object value, MetricsMode metricsMode) {
+    // ORC only stores min/max for String columns
+    if (value == null || metricsMode == MetricsModes.Full.get() || type.typeId() != Type.TypeID.STRING) {

Review comment:
       Might be better to check if the Metrics mode != Truncate, seems easier to read that way. Also we have a Precondition later to assert the same, which may be unnecessary if we make the check here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] edgarRd commented on pull request #1339: ORC: Use MetricsConfig

Posted by GitBox <gi...@apache.org>.
edgarRd commented on pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339#issuecomment-676836925


   Thanks for the review @shardulm94 - I've updated the PR.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] shardulm94 commented on pull request #1339: ORC: Use MetricsConfig

Posted by GitBox <gi...@apache.org>.
shardulm94 commented on pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339#issuecomment-679434266


   Since this has been open for additional comments for a while now I am merging this. We can handle any followups in a separate PR. Thanks @edgarRd for the PR!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] edgarRd commented on pull request #1339: ORC: Use MetricsConfig

Posted by GitBox <gi...@apache.org>.
edgarRd commented on pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339#issuecomment-679439331


   Thanks @shardulm94 !


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] edgarRd commented on a change in pull request #1339: ORC: Use MetricsConfig

Posted by GitBox <gi...@apache.org>.
edgarRd commented on a change in pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339#discussion_r473495404



##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcMetrics.java
##########
@@ -203,7 +227,29 @@ private static Metrics buildOrcMetrics(final long numOfRows, final TypeDescripti
       BooleanColumnStatistics booleanStats = (BooleanColumnStatistics) columnStats;
       max = booleanStats.getTrueCount() > 0;
     }
-    return Optional.ofNullable(Conversions.toByteBuffer(column.type(), max));
+    return Optional.ofNullable(Conversions.toByteBuffer(type, truncateIfNeeded(Bound.UPPER, type, max, metricsMode)));
+  }
+
+  private static Object truncateIfNeeded(Bound bound, Type type, Object value, MetricsMode metricsMode) {
+    // ORC only stores min/max for String columns
+    if (value == null || metricsMode == MetricsModes.Full.get() || type.typeId() != Type.TypeID.STRING) {

Review comment:
       Done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] shardulm94 edited a comment on pull request #1339: ORC: Use MetricsConfig

Posted by GitBox <gi...@apache.org>.
shardulm94 edited a comment on pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339#issuecomment-679434266


   The PR looks good! Since this has been open for additional comments for a while now I am merging this. We can handle any followups in a separate PR. Thanks @edgarRd for the PR!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] shardulm94 merged pull request #1339: ORC: Use MetricsConfig

Posted by GitBox <gi...@apache.org>.
shardulm94 merged pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] edgarRd commented on pull request #1339: ORC: Use MetricsConfig

Posted by GitBox <gi...@apache.org>.
edgarRd commented on pull request #1339:
URL: https://github.com/apache/iceberg/pull/1339#issuecomment-679245897


   @rdsr @aokolnychyi PTAL - do you have any comments?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org