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 38C24200CE6 for ; Thu, 17 Aug 2017 05:37:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 36CCD16A237; Thu, 17 Aug 2017 03:37:05 +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 7D1AA16A232 for ; Thu, 17 Aug 2017 05:37:04 +0200 (CEST) Received: (qmail 22963 invoked by uid 500); 17 Aug 2017 03:37:03 -0000 Mailing-List: contact issues-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 issues@drill.apache.org Received: (qmail 22954 invoked by uid 99); 17 Aug 2017 03:37:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2017 03:37:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B612EC3E53 for ; Thu, 17 Aug 2017 03:37:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.201 X-Spam-Level: X-Spam-Status: No, score=-99.201 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id tTh29EuO3RKX for ; Thu, 17 Aug 2017 03:37:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 8CB535F257 for ; Thu, 17 Aug 2017 03:37:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 0573FE0931 for ; Thu, 17 Aug 2017 03:37:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id B8B1125382 for ; Thu, 17 Aug 2017 03:37:00 +0000 (UTC) Date: Thu, 17 Aug 2017 03:37:00 +0000 (UTC) From: "Paul Rogers (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (DRILL-5525) Inconsistent, unhelpful semantics for batch, field schema comparison MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 17 Aug 2017 03:37:05 -0000 [ https://issues.apache.org/jira/browse/DRILL-5525?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul Rogers resolved DRILL-5525. -------------------------------- Resolution: Fixed > Inconsistent, unhelpful semantics for batch, field schema comparison > -------------------------------------------------------------------- > > Key: DRILL-5525 > URL: https://issues.apache.org/jira/browse/DRILL-5525 > Project: Apache Drill > Issue Type: Bug > Affects Versions: 1.10.0 > Reporter: Paul Rogers > Assignee: Paul Rogers > Priority: Minor > Fix For: 1.12.0 > > > Drill provides two classes to define schema at execution time: > * {{MaterializedField}} - describes one column (or a collection of columns for a map) > * {{BatchSchema}} - describes the set of columns that make up a row > Each class provides an {{isEqual()}} method. However it seems these methods may not be used much because the contain a number of flaws and contradictions. > * {{MaterializedField}} has a comment that says it compares only names; but then it turns around and compares the object field-by-field using Protobuf: > {code} > // DRILL-1872: Compute equals only on key. See also the comment > // in MapVector$MapTransferPair > return this.name.equalsIgnoreCase(other.name) && > Objects.equals(this.type, other.type); > {code} > * {{MaterializedField}} ends up doing a physical comparison of fields rather than a logical comparison. Varchar columns are defined, at the logical level as Varchar. But, at the physical level, a Varchar is a two-part column: it has a child that represents the {{$offsets$}} vector. As a result, a comparison between logical and physical schema returns false, even if both is just a Varchar. > * {{BatchSchema}} ends up being inconsistent because of the above confusion. It first (seemingly) compares names, then tries to compare types. But, because the {{MaterializedField}} method actually compares all fields, the type comparison does nothing. > {code} > if (!fields.equals(other.fields)) { // Compare all fields > return false; > } > for (int i = 0; i < fields.size(); i++) { // So this loop is a no-op > MajorType t1 = fields.get(i).getType(); > MajorType t2 = other.fields.get(i).getType(); > if (t1 == null) { > if (t2 != null) { > return false; > } > } else { > if (!majorTypeEqual(t1, t2)) { > return false; > } > } > } > {code} > The result is that one is not quite sure what the two methods are supposed to compare. Is {{MaterializedField}} supposed to: > * Do a physical compare (existing behavior)? > * Do a name-only compare (as the comment suggests)? > * Do a logical comparison (as unit tests would want)? > And for {{BatchSchema}}, should it: > * Do a physical compare (existing behavior)? > * Do a type-aware comparison (as in the loop that does nothing)? > Further note that neither of the methods do anything special for map fields: they end up being compared as part of the protobuf comparison. But, we shold probably apply the same rules to map fields as we apply to top-level fields (as expressed in the second loop above.) > This ticket requests: > * Document current uses. > * Determine the semantics of the {{isEqual()}} method. > * Create additional methods as needed: {{isPhysicallyEqual()}}, {{isLogicallyEqual()}}, {{hasSameNames()}}, or whatever. > Not that this issue is classic: it seems that "equal" is well defined concept, but as the Greek philosopher [Heraclitus|https://en.wikipedia.org/wiki/Heraclitus] suggested with his famous quote that "you can never step into the same river twice", the concept of "sameness" is fluid and ad-hoc. It is up to us to define the semantics for equality, and sometimes we need more than one concept. -- This message was sent by Atlassian JIRA (v6.4.14#64029)