Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMzMG-003mWe-Pg for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Jul 2023 23:16:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qMzMF-009wiE-8u for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Jul 2023 23:16:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMzME-009wi6-Va for pgsql-hackers@lists.postgresql.org; Fri, 21 Jul 2023 23:16:22 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qMzMC-000lH8-8A for pgsql-hackers@postgresql.org; Fri, 21 Jul 2023 23:16:21 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-262c42d3fafso1679755a91.0 for ; Fri, 21 Jul 2023 16:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timescale.com; s=google; t=1689981379; x=1690586179; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=lssx+QzsGZR/6lYVaf957PX3YsnP4b+juGmS6vCRq90=; b=FU+ycmju5tamMHjAJi7kNwFEsooXQy8w0dE884cv8uqC+3GkISmzM5TDV7boy2s0xF 0OdFPEju3qGSbQ3h9JifX5KWjGHvPO8Za/xmYefpzlQoJzettLT+wA5EMtHUk+ft7LZc f441x+mM9KeAtwAc4KIs0fXHo9LbucfK/JASoBy7LOMneb45p9aHVzgq0avirVis1GB6 UBmJ5FxBc7NUcaUjssOFp6LKfWvKckLGDv5pudv3Iohtm7xPSUcE3hweKxZK/KLUepCL jTZDosJJOuvESmd/3B6DsuMEjg/nMmsP19pM9rCYeJ+dqzjzOlaNKWcwKDe60HwARWmj UO4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689981379; x=1690586179; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lssx+QzsGZR/6lYVaf957PX3YsnP4b+juGmS6vCRq90=; b=eVgeX+OvwBO//REPi/AcMoVMgaK6Nh+egWa6VNKeQtkg9zT6bLSBHAypyTh4Q38mG/ mcJGc+fkRTDaQT9L6fgB+n5Mw4ZyOoZyFTqHk3Us3dPMSrsZgnij+ml2pRWHQ/g5MIsJ tDlYySQapdQwKT8LuNBrrT1kDxMdNAShqxzkLB/i8T7gp8x8GI+1p7t6ZWYfQIjmywb/ aQtEcj819mpR1wsKY2PkyknZ/zOKUz5N2qvdiboXO9eb5kbG3ZObeO+fxWeowOsQOJX7 rLEez1RgfuI5zrSXSoi4gh7TSGWlrCs9DA7y98zXtVPtkhiU+lAUhcU0jfjoYpnnzRKJ WRdA== X-Gm-Message-State: ABy/qLay9n5LT1a0l3b3EKnplANn8pt4hh07Dv98HqBrgJHeQ0JNoOJy 3viTNq4fK+uzC6O2XSrnhH8zWdDCjrcOb1ra/5yWBg== X-Google-Smtp-Source: APBJJlEt6LIkNWO4GXfSDT37UPdcSUkNHKbiF6k29Io0SQ0E4RoVm3oIg/+Q3HlXS53H/xVyvmR7lQ== X-Received: by 2002:a17:90b:4c92:b0:261:219b:13b3 with SMTP id my18-20020a17090b4c9200b00261219b13b3mr5080325pjb.16.1689981379163; Fri, 21 Jul 2023 16:16:19 -0700 (PDT) Received: from [192.168.1.21] ([50.53.8.205]) by smtp.gmail.com with ESMTPSA id w5-20020a17090a380500b0025e7f7b46c3sm5101588pjb.25.2023.07.21.16.16.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Jul 2023 16:16:18 -0700 (PDT) Message-ID: Date: Fri, 21 Jul 2023 16:16:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: Row pattern recognition Content-Language: en-US To: Tatsuo Ishii Cc: pgsql-hackers@postgresql.org, vik@postgresfriends.org References: <07214b3a-5893-f6ce-ef55-0e5d24c94925@timescale.com> <20230720.141513.1986681389874528348.t-ishii@sranhm.sra.co.jp> <022a392f-2a9e-3df1-a509-a5bd51160fa5@timescale.com> <20230721.151648.412762379013769790.t-ishii@sranhm.sra.co.jp> From: Jacob Champion In-Reply-To: <20230721.151648.412762379013769790.t-ishii@sranhm.sra.co.jp> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/20/23 23:16, Tatsuo Ishii wrote: > I don't know at this point. I think context-free is not enough to be > repsented in Bison. The grammer also needs to be LALR(1). Moreover, > adding the grammer to existing parser may generate shift/reduce > errors. Ah. It's been too long since my compilers classes; I will pipe down. > One small concern is how to convert pattern variables to regex > expression which our regex enginer understands. Suppose, > > PATTERN UP+ > > Currently I convert "UP+" to "U+" so that it can be fed to the regexp > engine. In order to do that, we need to know which part of the pattern > (UP+) is the pattern variable ("UP"). For "UP+" it's quite easy. But > for more complex regular expressions it would be not, unless PATTERN > grammer can be analyzed by our parser to know which part is the > pattern variable. Is the eventual plan to generate multiple alternatives, and run the regex against them one at a time? >> I'm not familiar enough with this code yet to offer very concrete >> suggestions, sorry... But at some point in the future, we need to be >> able to skip forward and backward from arbitrary points, like >> >> DEFINE B AS B.price > PREV(FIRST(A.price), 3) >> >> so there won't be just one pair of "previous and next" tuples. > > Yes, I know. I apologize. I got overexplain-y. >> Maybe >> that can help clarify the design? It feels like it'll need to eventually >> be a "real" function that operates on the window state, even if it >> doesn't support all of the possible complexities in v1. > > Unfortunately an window function can not call other window functions. Can that restriction be lifted for the EXPR_KIND_RPR_DEFINE case? Or does it make sense to split the pattern navigation "functions" into their own new concept, and maybe borrow some of the window function infrastructure for it? Thanks! --Jacob