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 DC05C200B58 for ; Wed, 27 Jul 2016 21:51:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D90EC160A90; Wed, 27 Jul 2016 19:51:46 +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 012E5160A6F for ; Wed, 27 Jul 2016 21:51:45 +0200 (CEST) Received: (qmail 46913 invoked by uid 500); 27 Jul 2016 19:51:45 -0000 Mailing-List: contact dev-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list dev@ignite.apache.org Received: (qmail 46901 invoked by uid 99); 27 Jul 2016 19:51:44 -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; Wed, 27 Jul 2016 19:51:44 +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 6DA78CD786 for ; Wed, 27 Jul 2016 19:51:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.021 X-Spam-Level: X-Spam-Status: No, score=-0.021 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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=gridgain-com.20150623.gappssmtp.com Received: from mx2-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 9z7T7WjFr2vy for ; Wed, 27 Jul 2016 19:51:43 +0000 (UTC) Received: from mail-yw0-f170.google.com (mail-yw0-f170.google.com [209.85.161.170]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id 4C32F60E35 for ; Wed, 27 Jul 2016 19:51:43 +0000 (UTC) Received: by mail-yw0-f170.google.com with SMTP id r9so67324699ywg.0 for ; Wed, 27 Jul 2016 12:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gridgain-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=8odEGz6r7zv/6+28iwIihEe57cq2W+p2iTEUZ3z6qKA=; b=gSjBawd6zO5WeruTYP3Fwjzx3IfbHgyns5BDy8eJfQF6LyvjUHF0x9kpup6nn8Qven X0Q8UXzn1VrR2tcpPTUIi6jZGTsppIrH5DnVZabZHUr5Sd6fc1ntT7bn+Lzpw5eF+5mB bjoL676T+5ePzS52y4ZQRhXMsshtnRf2Cz4oPGJjALGrNrsweHCnpXIdSi85yeR28/NK YwLu08q1JMgrzZDKRtKPmaW9r3a2EWuCMYjAAuPUA/XBN45IYj+K2nUSGyuSlCqoilTJ ilH6Qm2/eYOowyC27G2VoVBv2OjeSqVbcO+0LUUn/eG1mHL+ghUkveupxGOyn7tZiUBx 8kLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=8odEGz6r7zv/6+28iwIihEe57cq2W+p2iTEUZ3z6qKA=; b=ZxiZ8Ev9rpJUjtPNeWBT08LVsmtaCw6ixxJXfku7ezXorUq6qm0kjT+3RrW56xcQNU 4DFRpZf6M2Z6nWl7Hwnfj0uk7bZ2jXdOBXgF13nkbG2yYNzfnzcWQ+eQnaz2YbmogyYt joDaiMTqHEBZgx6hZQPLzdZsnMRtW0iW/biTDGLsGWk3d1zQnimYoHz/eIJ17L+KKcOm Nsbjfkvq3DSRxuflDXzzlwZumBdR64CITrXpv/78u4jVwDy2C+/e6gaBX+0epAqj7Dnv OMdRmqkzJaT3eJCA8Huh6Kiptv4uojL2ZMtoivQhXgKvOeH6BGqezZbcI7YattJNQIyB 7xHA== X-Gm-Message-State: AEkoousaFTLpIixC3nCbwWLce9fOLoQPS61gpakBTWtX3DW2wcFu4AcnGOeRqp1HnqVBI6UV X-Received: by 10.37.126.1 with SMTP id z1mr26109518ybc.57.1469649102555; Wed, 27 Jul 2016 12:51:42 -0700 (PDT) Received: from [10.130.198.158] ([166.170.55.19]) by smtp.gmail.com with ESMTPSA id c124sm3665763ywh.28.2016.07.27.12.51.40 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jul 2016 12:51:41 -0700 (PDT) Content-Type: text/plain; charset=koi8-r Mime-Version: 1.0 (1.0) Subject: Re: Enums and SQL queries From: Dmitriy Setrakyan X-Mailer: iPhone Mail (13F69) In-Reply-To: Date: Wed, 27 Jul 2016 15:51:39 -0400 Cc: Valentin Kulichenko Content-Transfer-Encoding: quoted-printable Message-Id: References: To: dev@ignite.apache.org archived-at: Wed, 27 Jul 2016 19:51:47 -0000 Sorry, Sergi. What I meant is to file a ticket with the design you suggested= Dmitriy > On Jul 27, 2016, at 9:18 AM, Sergi Vladykin wro= te: >=20 > I don't see how this can work to file a ticket, could you please give more= > details? >=20 > Sergi >=20 > 2016-07-27 15:50 GMT+03:00 Dmitriy Setrakyan : >=20 >> Sergi, I still thinks my solution works or can be made to work. In the >> example you provided, you can choose to return either String or Enum as t= he >> query result. However, this is not a clean solution, I agree, but could b= e >> a quick one. >>=20 >> I don't mind breaking compatibility on this issue, given that it never >> worked properly anyway. Can you please file a ticket? >>=20 >> D. >>=20 >> On Wed, Jul 27, 2016 at 3:01 AM, Sergi Vladykin >> wrote: >>=20 >>> Nope. This will not work. Because take for example the following query: >>>=20 >>> select my_enum_field from my_table where my_enum_field =3D 'BLA' >>>=20 >>> Field well be evaluated only once here, but it must be a Sting and Enum >> at >>> the same time. >>=20 >>=20 >>> Probably we could contribute to H2 `User defined value types` and handle= >>> this stuff in our own Enum value types, which will support comparison >> with >>> String. But this requires bug H2 Modification and is a compatibility >>> breaking change. >>>=20 >>> Sergi >>>=20 >>>=20 >>>=20 >>> 2016-07-27 9:23 GMT+03:00 Dmitriy Setrakyan : >>>=20 >>>> Hm... I would prefer to find a way to handle Enums automatically. >>>>=20 >>>> In case if user expects a String, can we catch an exception and do >>>> automatic conversion at that time? In this case, we could catch the >>>> exception once and remember the decision. Will something like this >> work? >>>>=20 >>>> D. >>>>=20 >>>> On Tue, Jul 26, 2016 at 1:49 AM, Sergi Vladykin < >>> sergi.vladykin@gmail.com> >>>> wrote: >>>>=20 >>>>> GridQueryProcessor contains two types: BinaryProperty and >>> ClassProperty. >>>>> Indexing uses them for fields access. Probably we can change them, so >>>> that >>>>> they will always return String instead of Enum type but this >>>>>=20 >>>>> 1. looks like a compatibility breaking change; >>>>> 2. users doing queries like `select my_enum_field from my_table` >>> probably >>>>> still expect to get a Enum result but not a String. >>>>>=20 >>>>> What do you think? >>>>>=20 >>>>> Sergi >>>>>=20 >>>>>=20 >>>>> 2016-07-26 3:17 GMT+03:00 Valentin Kulichenko < >>>>> valentin.kulichenko@gmail.com >>>>>> : >>>>>=20 >>>>>> Sergi, >>>>>>=20 >>>>>> Ideally, I would like this query to work: >>>>>>=20 >>>>>> select * from MyTable where myEnumField =3D 'MY_ENUM_NAME' >>>>>>=20 >>>>>> The problem is that the field value is not a string, it's a binary >>>> object >>>>>> with the enum value ordinal inside. We can add enum value names >> into >>>> the >>>>>> metadata, so that we can always map the field value to its string >>>>>> representation, but SQL engine will have to know how to use it. Is >>> this >>>>>> possible? >>>>>>=20 >>>>>> -Val >>>>>>=20 >>>>>> On Fri, Jul 22, 2016 at 10:25 PM, Sergi Vladykin < >>>>> sergi.vladykin@gmail.com >>>>>>> wrote: >>>>>>=20 >>>>>>> I'm not sure what exactly you are going to patch in SQL engine. We >>>> could >>>>>>> and some SQL function like enum('MY_ENUM_NAME') but probably it >> will >>>> not >>>>>>> work if we will not pass enum type there as well, so it have look >>> like >>>>>>> enum('com.mycompany.MyEnum', 'MY_ENUM_NAME') which is ugly. >>>>>>>=20 >>>>>>> Sergi >>>>>>>=20 >>>>>>> On 23 =C9=C0=CC=D1 2016 =C7., 0:43, Valentin Kulichenko < >>>>>>> valentin.kulichenko@gmail.com >>>>>>>> wrote: >>>>>>>=20 >>>>>>>> Folks, >>>>>>>>=20 >>>>>>>> I noticed that we currently have a very weird limitation for >> enum >>>>> fields >>>>>>>> when running SQL queries. Basically, you can't use enum value >>> names >>>> as >>>>>>> many >>>>>>>> users would expect. >>>>>>>>=20 >>>>>>>> Technically this happens because binary format stores only >> ordinal >>>> and >>>>>>> the >>>>>>>> only way to run such query is to do something like this: >>>>>>>>=20 >>>>>>>> SqlFieldsQuery qry =3D new SqlFieldsQuery("select * from Table >> where >>>>>>>> enumField =3D ?"); >>>>>>>> qry.setArgs(MyEnum.ENUM_VALUE); >>>>>>>> cache.query(qry); >>>>>>>>=20 >>>>>>>> This means that this query can be executed only if: >>>>>>>> - IgniteCache API is used. So it doesn't work in JDBC driver, >>>>> Zeppelin, >>>>>>>> etc. >>>>>>>> - The client that executes the query has the enum class on >>>> classpath. >>>>>>>>=20 >>>>>>>> My first thought about fixing this is to somehow store value >> names >>>> in >>>>>>>> binary metadata and patch the SQL engine so that it understands >>> how >>>> to >>>>>>> use >>>>>>>> this information. >>>>>>>>=20 >>>>>>>> Thoughts? >>>>>>>>=20 >>>>>>>> -Val >>=20