Return-Path: X-Original-To: apmail-asterixdb-dev-archive@minotaur.apache.org Delivered-To: apmail-asterixdb-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D778417A12 for ; Tue, 22 Sep 2015 10:43:06 +0000 (UTC) Received: (qmail 27218 invoked by uid 500); 22 Sep 2015 10:43:06 -0000 Delivered-To: apmail-asterixdb-dev-archive@asterixdb.apache.org Received: (qmail 27163 invoked by uid 500); 22 Sep 2015 10:43:06 -0000 Mailing-List: contact dev-help@asterixdb.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.incubator.apache.org Delivered-To: mailing list dev@asterixdb.incubator.apache.org Received: (qmail 27148 invoked by uid 99); 22 Sep 2015 10:43:06 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Sep 2015 10:43:06 +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 14E88F58CD for ; Tue, 22 Sep 2015 10:43:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.879 X-Spam-Level: ** X-Spam-Status: No, score=2.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id gC6nvUU_TDj8 for ; Tue, 22 Sep 2015 10:43:05 +0000 (UTC) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 7EA7044161 for ; Tue, 22 Sep 2015 10:43:04 +0000 (UTC) Received: by wiclk2 with SMTP id lk2so17227060wic.1 for ; Tue, 22 Sep 2015 03:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=AsehspV8poqJTVVG8CKLTg9gdWv0o5uFJYlOgdzSPFE=; b=nhla+JyaggUuZZRpTXMCZVdurruU9eflkEDJBvyRURqy36S/P1noPBgZK9AbzFKZjZ qsjAxihN2CHdncKnBMn+shByIvN/Ub9nxpSkB8f0qyNn4q3uOqfPqHy2ki6I45J/am9t xf0rxKfCGJvBbRRAwP854oTd4njXU5vnUwKufiY/LeLh0R5K/qHJupKPtwU3q2/nE8pB Gm2K8rMqqi42ABAO2WtODHD+/Ye+dZRTHZWXmdUQmyScspgAl5UEDCqF4jVBk2Iq+p4p r1+f4NQW+dAUjQbTSTR5I6bOc8iFZTOBenl7t9PckFttK3uNZ6Dz7ofLCCcPuKihqXpJ DGNQ== MIME-Version: 1.0 X-Received: by 10.194.113.101 with SMTP id ix5mr32240152wjb.66.1442918583627; Tue, 22 Sep 2015 03:43:03 -0700 (PDT) Received: by 10.27.17.194 with HTTP; Tue, 22 Sep 2015 03:43:03 -0700 (PDT) In-Reply-To: References: <66B07D26-F281-433C-9150-383AD217DA26@gmail.com> Date: Tue, 22 Sep 2015 13:43:03 +0300 Message-ID: Subject: Re: Question about open indexes From: abdullah alamoudi To: dev@asterixdb.incubator.apache.org Content-Type: multipart/alternative; boundary=001a1130c8c69df4c8052053a95d --001a1130c8c69df4c8052053a95d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Never mind, I figured it out. The cast in red actually changes the record in primary index into the casted record. The cast before the insert operator into the primary index actually casts from the input to the open type since they are compatible. Regards, Abdullah. Amoudi, Abdullah. On Tue, Sep 22, 2015 at 11:19 AM, abdullah alamoudi wrote: > @Ildar, > If that is the case, then why do we cast as well after the primary index > insert operator. If all the records are casted already, then why is the > second cast needed? > > For example, look at the following plan: > Statement: > insert into dataset OrdersOpen ( > for $x in dataset Orders > return $x > ); > Plan: > commit > -- COMMIT |PARTITIONED| > project ([$$3]) > -- STREAM_PROJECT |PARTITIONED| > exchange > -- ONE_TO_ONE_EXCHANGE |PARTITIONED| > insert into idx_Orders_Custkey on tpch:OrdersOpen from [%0->$$7] > -- INDEX_INSERT_DELETE |PARTITIONED| > exchange > -- ONE_TO_ONE_EXCHANGE |PARTITIONED| > project ([$$3, $$7]) > -- STREAM_PROJECT |PARTITIONED| > assign [$$7] <- [function-call: asterix:field-access-by-index= , > Args:[function-call: asterix:cast-record, Args:[%0->$$4], AInt32: {8}]] > -- ASSIGN |PARTITIONED| > exchange > -- ONE_TO_ONE_EXCHANGE |PARTITIONED| > insert into tpch:OrdersOpen from %0->$$4 partitioned by > [%0->$$3] > -- INSERT_DELETE |PARTITIONED| > exchange > -- HASH_PARTITION_EXCHANGE [$$3] |PARTITIONED| > assign [$$3] <- [function-call: > asterix:field-access-by-index, Args:[%0->$$4, AInt32: {0}]] > -- ASSIGN |PARTITIONED| > project ([$$4]) > -- STREAM_PROJECT |PARTITIONED| > assign [$$4] <- [function-call: > asterix:cast-record, Args:[%0->$$0]] > -- ASSIGN |PARTITIONED| > project ([$$0]) > -- STREAM_PROJECT |PARTITIONED| > exchange > -- ONE_TO_ONE_EXCHANGE |PARTITIONED| > data-scan []<-[$$5, $$0] <- tpch:Orders > -- DATASOURCE_SCAN |PARTITIONED| > exchange > -- ONE_TO_ONE_EXCHANGE |PARTITIONED| > empty-tuple-source > -- EMPTY_TUPLE_SOURCE |PARTITIONED| > > what is the point of the cast in red? > > > Amoudi, Abdullah. > > On Tue, Sep 22, 2015 at 10:18 AM, abdullah alamoudi > wrote: > >> I see. >> Thanks Ildar, >> >> Abdullah. >> >> Amoudi, Abdullah. >> >> On Tue, Sep 22, 2015 at 10:04 AM, Ildar Absalyamov < >> ildar.absalyamov@gmail.com> wrote: >> >>> Abdullah, >>> >>> If I remember correctly whenever a secondary open index is created all >>> existing records would be casted to a proper type to ensure that the in= dex >>> creation is valid. >>> As for the overall correctness of casting operation, semantically >>> creating an open index is the same thing as altering the dataset type. = The >>> current implementation allows only one open index of particular type >>> created on a single field. If we would have had =E2=80=9Calter datatype= =E2=80=9D >>> functionality the open indexing would not be required at all. >>> >>> > On Sep 21, 2015, at 23:25, abdullah alamoudi >>> wrote: >>> > >>> > More thoughts: >>> > I assume the intention of the cast was just to make sure if the open >>> field >>> > exists, it is of the specified type. Moreover, the un-casted record >>> should >>> > be inserted into the index. >>> > If my assumptions are not correct, please, let me know ASAP. >>> > >>> > I have two thoughts on this: >>> > 1. Actually, insert plans show that the records being inserted into t= he >>> > primary index is actually the casted record creating the issue >>> described >>> > above. >>> > >>> > 2. I don't believe this is the right way to ensure that the open fiel= d >>> if >>> > exists is of the right type. why not extract the field using field >>> access >>> > by name function and then verify the type using the field tag? >>> > >>> > >>> > >>> > On Tue, Sep 22, 2015 at 9:11 AM, abdullah alamoudi >>> > wrote: >>> > >>> >> Hi Dev, @Ildar, >>> >> >>> >> In the insert pipeline for datasets with open indexes, we introduce = a >>> cast >>> >> function before the insert and so one would expect the records to >>> look like >>> >> the casted record type which I assume has {{the closed fields + a >>> nullable >>> >> field}}. >>> >> >>> >> The question is, what happens to the previously existing records?, >>> since >>> >> now the index has both, records of the original type and records of >>> the >>> >> casted type. >>> >> >>> >> Thanks, >>> >> Abdullah. >>> >> >>> >>> Best regards, >>> Ildar >>> >>> >> > --001a1130c8c69df4c8052053a95d--