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 BAAAE200C14 for ; Tue, 7 Feb 2017 12:49:16 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B91B5160B4B; Tue, 7 Feb 2017 11:49:16 +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 0CFE3160B3E for ; Tue, 7 Feb 2017 12:49:15 +0100 (CET) Received: (qmail 60166 invoked by uid 500); 7 Feb 2017 11:49:15 -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 60155 invoked by uid 99); 7 Feb 2017 11:49:15 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2017 11:49:15 +0000 Received: from mail-oi0-f50.google.com (mail-oi0-f50.google.com [209.85.218.50]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id E2BA91A060E for ; Tue, 7 Feb 2017 11:49:14 +0000 (UTC) Received: by mail-oi0-f50.google.com with SMTP id s203so63181789oie.1 for ; Tue, 07 Feb 2017 03:49:14 -0800 (PST) X-Gm-Message-State: AMke39kyzmk0+o2zwVBFJGF3Wo6CPQOHDvx3t+zQZFhl6OSNkvzQJniZsoT+msKnEnBHfVRh50wr1B98f/jKTLOk X-Received: by 10.202.194.137 with SMTP id s131mr6608160oif.140.1486468154170; Tue, 07 Feb 2017 03:49:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.54.129 with HTTP; Tue, 7 Feb 2017 03:48:43 -0800 (PST) In-Reply-To: References: From: Pavel Tupitsyn Date: Tue, 7 Feb 2017 14:48:43 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Rethink native SQL API in Apache Ignite 2.0 To: dev@ignite.apache.org Content-Type: multipart/alternative; boundary=001a113d661e4cc25e0547ef563b archived-at: Tue, 07 Feb 2017 11:49:16 -0000 --001a113d661e4cc25e0547ef563b Content-Type: text/plain; charset=UTF-8 +1 SqlFieldsQuery API is quite a convoluted way to do DML. 2.0 release should certainly address this. On Tue, Feb 7, 2017 at 2:34 PM, Vladimir Ozerov wrote: > Igniters, > > Our SQL engine becomes more and more sophisticated. Initially we had only > SELECTs, now we have DML, in AI 2.x we will have DDL. > > This is very cool, but it seems that we completely forgot about extending > our native SQL API (IgniteCache.query, SqlQuery, SqlFieldsQuery) in > response to these changes. For example: > > 1) How one should execute DML/DDL command and validate the result? > int updateCnt = IgniteCache.query(SqlQuery).getAll().get(0); > > Counter-intuitive and too verbose. > > 2) How one should perform batched operations? One by one? > IgniteCache.query(SqlQuery.setArgs(1)); > IgniteCache.query(SqlQuery.setArgs(2)); > ... > IgniteCache.query(SqlQuery.setArgs(N)); > > I think it is time to rework our API so that it supports all recent > features in consistent way and is extensible enough for future improvements > (e.g. transactional SQL). > > Probably we can take ideas behind JDBC standard as starting point and move > SQL to separate API. Several very rough examples: > > 1) Getting facade: > IgniteSql sql = ignite.sql("MY_SCHEMA"); > > 2) Running SELECT: > QueryCursor cursor = sql.select(SqlCommand); > QueryCursor> cursor = sql.selectFields(SqlCommand); // No more need > for separate SqlQuery and SqlQueryFields classes. > > 3) Running DML/DDL: > SqlCommandResult res = sql.execute(SqlCommand); > or > int updatedCnt = sql.execute(SqlCommand); > > 4) Running batch commands: > SqlCommand cmd = new SqlCommand(...).addBatch(arg1).addBatch(arg2); > SqlCommandResult res = sql.execute(cmd); > > 5) Re-use query parsing results (PreparedStatement): > SqlCommand qry = sql.prepare("SELECT ..."); > > Our JDBC driver is not applicable here because it is either not peformant > enough (V1), or starts unnecessary client inside (V2). > > Thoughts? Does anyone else think it is time to re-approach SQL API? > > Vladimir. > --001a113d661e4cc25e0547ef563b--