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 A0C73200BB4 for ; Tue, 1 Nov 2016 17:34:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9F56C160AF7; Tue, 1 Nov 2016 16:34:00 +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 BE9B3160ADA for ; Tue, 1 Nov 2016 17:33:59 +0100 (CET) Received: (qmail 56046 invoked by uid 500); 1 Nov 2016 16:33:58 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 56035 invoked by uid 99); 1 Nov 2016 16:33:58 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2016 16:33:58 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id DA8D2C0C0D for ; Tue, 1 Nov 2016 16:33:57 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.88 X-Spam-Level: * X-Spam-Status: No, score=1.88 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=winguzone.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id EyWZQYskUGJX for ; Tue, 1 Nov 2016 16:33:55 +0000 (UTC) Received: from sender163-mail.zoho.com (sender163-mail.zoho.com [74.201.84.163]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 265785F2C3 for ; Tue, 1 Nov 2016 16:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1478018025; s=zoho; d=winguzone.com; i=vladyu@winguzone.com; h=Date:From:To:Message-Id:In-Reply-To:References:Subject:MIME-Version:Content-Type; l=7944; bh=2Kx4qixYLW2Sk/pIhCnOJYJZnZB0t2uCIsh5ETTCdj8=; b=U27Bfru65mE8aP/YPZdEVs2jIrzw22xbfvhtBcMp1pWFq9bXYRVXDfWMweInML4F dgcgapr/auv94kASfxuJGK6aYeWXDlTYkEdo+TEcyPYOYETJXrEQfKOWMkk3cd7JDt7 XxHEbftMNfCHWUw84mRbAoeVcHziFUfRGIS+ifMg= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 1478018025307397.42466439850136; Tue, 1 Nov 2016 09:33:45 -0700 (PDT) Date: Tue, 01 Nov 2016 12:33:45 -0400 From: Vladimir Yudovin To: "user" Message-Id: <15820bd473d.d4cd1994738593.2664497976285731044@winguzone.com> In-Reply-To: References: Subject: Re: Specifying multiple conditions for lightweight conditions? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2283693_919672688.1478018025305" X-Priority: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail archived-at: Tue, 01 Nov 2016 16:34:00 -0000 ------=_Part_2283693_919672688.1478018025305 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Hi, Unfortunately CQL syntax doesn't allow use of OR operator in condition list: UPDATE [ keyspace_name. ] table_name [ USING TTL time_value | USING TIMESTAMP timestamp_value ] SET assignment [ , assignment ] . . . WHERE row_specification [ IF EXISTS | IF NOT EXISTS | IF condition [ AND condition ] . . . ] ; The simplest solution to make two different request, first with null check: UPDATE project SET last_due_at = '2013-01-01 00:00:00+0200' WHERE id = '1' IF last_due_at = null; then test result, if applied = False make second request: UPDATE project SET last_due_at = '2013-01-01 00:00:00+0200' WHERE id = '1' IF last_due_at < '2013-01-01 00:00:00+0200' Sure, it's less effective then OR condition. Probably you can use IF NOT EXISTS in first request (depending on your application logic), may be it will be slightly faster (not sure). Best regards, Vladimir Yudovin, Winguzone - Hosted Cloud Cassandra Launch your cluster in minutes. ---- On Tue, 01 Nov 2016 08:22:31 -0400Ali Akhtar <ali.rac200@gmail.com> wrote ---- In the following query: UPDATE project SET last_due_at = '2013-01-01 00:00:00+0200' WHERE id = '1' IF last_due_at < '2013-01-01 00:00:00+0200'; The intent is to change the value of 'last_due_at' as long as 'last_due_at' isn't already set to a later date than the one I've supplied. The problem is, last_due_at starts off with an initial value of null, so the above query fails. If I try the following: UPDATE project SET last_due_at = '2013-01-01 00:00:00+0200' WHERE id = '1' IF last_due_at < '2013-01-01 00:00:00+0200' OR last_due_at = null; That fails due to a syntax error. Is there any other way to achieve this? ------=_Part_2283693_919672688.1478018025305 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =
Hi,

Unfortunately CQL synta= x doesn't allow use of OR operator in condition lis= t:

<= code>UPDATE [ keyspace_= name. ] table_name [ USING TTL time_value | USING TIMESTAMP= timestamp_value ] SET assignment<= span class=3D"hljs-operator"> [ , assignment ] . . . WHERE row_specification [ IF EXISTS | IF NOT EXISTS | IF condition [ AND condition = ] . . . ] ;

The simplest solution to make two diff= erent request, first with null check:

UPDATE project SET las= t_due_at =3D '2013-01-01 00:00:00+0200' WHERE id =3D '1' IF last_due_a= t =3D null;
then test result, if applied =3D False mak= e second request:

UPDATE project SET last_due_at =3D '2013-0= 1-01 00:00:00+0200' WHERE id =3D '1' IF last_due_at < '2013-01-01 0= 0:00:00+0200'

Sure, it's less effective= then OR condition. Probably you can use IF NOT EXISTS in first request (de= pending on your application logic), may be it will be slightly faster (not = sure).


Best regard= s, Vladimir Yudovin,
Winguzone - Hosted Cloud Cassandra
Launc= h your cluster in minutes.


---- On Tue, 01 Nov 2016 08:22:3= 1 -0400Ali Akhtar <ali.rac200@gmail.com> wrote ----
<= /div>

In the follow= ing query:

UPDATE project SET last_due_at= =3D '2013-01-01 00:00:00+0200'
WHERE id =3D '1' 
IF last_due_at < '2013-01-01 00:00:00+0200';

The intent is to change the value of 'last_due_at' as long = as 'last_due_at' isn't already set to a later date than the one I've suppli= ed.

The problem is, last_due_at starts off wit= h an initial value of null, so the above query fails.

If I try the following:


=
UPDATE project SET last_due_at =3D '2013-01-01 00:00:00+0200'
WHERE id =3D '1' 
IF last_due_at < = '2013-01-01 00:00:00+0200' OR last_due_at =3D null;
That fails due to a syntax error.

= Is there any other way to achieve this?
<= /div>

------=_Part_2283693_919672688.1478018025305--