Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E1B44200C4E for ; Fri, 21 Apr 2017 12:38:34 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E04AC160BA2; Fri, 21 Apr 2017 10:38:34 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3330F160B97 for ; Fri, 21 Apr 2017 12:38:34 +0200 (CEST) Received: (qmail 21022 invoked by uid 500); 21 Apr 2017 10:38:33 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 13698 invoked by uid 99); 21 Apr 2017 10:36:53 -0000 Received: from Unknown (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Apr 2017 10:36:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E7079F49E6; Fri, 21 Apr 2017 10:36:52 +0000 (UTC) From: arina-ielchiieva To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request #805: Drill-4139: Exception while trying to prune partiti... Content-Type: text/plain Message-Id: <20170421103652.E7079F49E6@git1-us-west.apache.org> Date: Fri, 21 Apr 2017 10:36:52 +0000 (UTC) archived-at: Fri, 21 Apr 2017 10:38:35 -0000 Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/805#discussion_r112660688 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetReaderUtility.java --- @@ -181,6 +185,71 @@ else if (parquetTableMetadata instanceof Metadata.ParquetTableMetadata_v2 && } /** + * Checks that the metadata file was created by drill with version less that + * the version where was changed the serialization of BINARY values + * and assigns byte arrays to min/max values obtained from the deserialized string. + * + * @param parquetTableMetadata table metadata that should be corrected + */ + public static void correctBinaryInMetadataCache(Metadata.ParquetTableMetadataBase parquetTableMetadata) { + if (hasOldBinarySerialization(parquetTableMetadata)) { + Set> names = Sets.newHashSet(); + if (parquetTableMetadata instanceof Metadata.ParquetTableMetadata_v2) { + for (Metadata.ColumnTypeMetadata_v2 columnTypeMetadata : + ((Metadata.ParquetTableMetadata_v2) parquetTableMetadata).columnTypeInfo.values()) { + if (columnTypeMetadata.primitiveType == PrimitiveTypeName.BINARY) { + names.add(Arrays.asList(columnTypeMetadata.name)); + } + } + } + for (Metadata.ParquetFileMetadata file : parquetTableMetadata.getFiles()) { + // Drill has only ever written a single row group per file, only need to correct the statistics + // on the first row group + Metadata.RowGroupMetadata rowGroupMetadata = file.getRowGroups().get(0); + for (Metadata.ColumnMetadata columnMetadata : rowGroupMetadata.getColumns()) { + // Setting Min/Max values for ParquetTableMetadata_v1 + if (parquetTableMetadata instanceof Metadata.ParquetTableMetadata_v1 + || parquetTableMetadata instanceof Metadata.ParquetTableMetadata_v3) { + PrimitiveTypeName primitiveType = columnMetadata.getPrimitiveType(); + if (primitiveType == PrimitiveTypeName.BINARY && columnMetadata.hasSingleValue()) { + Object minValue = columnMetadata.getMinValue(); + if (minValue != null && minValue instanceof String) { + byte[] bytes = ((String) minValue).getBytes(); + columnMetadata.setMax(bytes); + columnMetadata.setMin(bytes); + } + } + } + // Setting Max values for ParquetTableMetadata_v2 + else if (parquetTableMetadata instanceof Metadata.ParquetTableMetadata_v2 + && columnMetadata.hasSingleValue() + && names.contains(Arrays.asList(columnMetadata.getName()))) { + Object maxValue = columnMetadata.getMaxValue(); + if (maxValue != null && maxValue instanceof String) { + byte[] bytes = ((String) maxValue).getBytes(); + columnMetadata.setMax(bytes); + } + } + } + } + } + } + + /** + * Checks that the metadata file was created by drill with version less that + * the version where was changed the serialization of BINARY values. + * + * @param parquetTableMetadata the source of drill version + * @return true if metadata file was created by drill with version less that + * the version where was changed the serialization of BINARY values + */ + public static boolean hasOldBinarySerialization(Metadata.ParquetTableMetadataBase parquetTableMetadata) { + String drillVersion = parquetTableMetadata.getDrillVersion(); + return drillVersion == null + || new ComparableVersion(drillVersion).compareTo(new ComparableVersion("1.11.0-SNAPSHOT")) < 0; --- End diff -- I am not sure that using version with SNAPSHOT is correct. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---