Return-Path: X-Original-To: apmail-ignite-dev-archive@minotaur.apache.org Delivered-To: apmail-ignite-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 7024D18965 for ; Fri, 12 Feb 2016 09:36:14 +0000 (UTC) Received: (qmail 7448 invoked by uid 500); 12 Feb 2016 09:36:14 -0000 Delivered-To: apmail-ignite-dev-archive@ignite.apache.org Received: (qmail 7407 invoked by uid 500); 12 Feb 2016 09:36:14 -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 7395 invoked by uid 99); 12 Feb 2016 09:36:14 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Feb 2016 09:36:14 +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 928EFC0C99 for ; Fri, 12 Feb 2016 09:36:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.979 X-Spam-Level: * X-Spam-Status: No, score=1.979 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, 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: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gridgain-com.20150623.gappssmtp.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id j0EcS5rp7IZn for ; Fri, 12 Feb 2016 09:36:10 +0000 (UTC) Received: from mail-yw0-f179.google.com (mail-yw0-f179.google.com [209.85.161.179]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 806F42565F for ; Fri, 12 Feb 2016 09:36:09 +0000 (UTC) Received: by mail-yw0-f179.google.com with SMTP id q190so60522260ywd.3 for ; Fri, 12 Feb 2016 01:36:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gridgain-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=gQKRMg4pqBXg4n9MOnFkWD8h6KomHWl3MW7gq1k431Q=; b=V8KDxoJ/AYgS6TuBuDlFK/R7F4+tX0aO8EkhfstX6E7Q0z+BCsAJmVxYj5ca/lyH3D J7yM/555j8WMXzKFLZf6bxJbfB3d7WPatXxm/GwoKYHoWT/zo5G518iv8e7a69UE7A7o VbXGoElp3QA6q4cB2J0F7NGGITYR9rC/8jetiUGlExRDqNWXrDcsdvThQhqkN5/V5mxA 3g14Nz4WmhOHuT8RtIVBoJS+ZQRN+aXKhsCoJ3qUrF5mz3+Gq6bL7kqEE+skwwUJqbTH AnCRCMQDD/acp1FcfbmlOD+Sgzab4OZJRbsDtsSmUvQqlPRHwW7cdVoU/iKO95BrxJI5 +UsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=gQKRMg4pqBXg4n9MOnFkWD8h6KomHWl3MW7gq1k431Q=; b=AcNXh/7TSnS58dxtzMeXsbt3zsX3JP7cJcQBavEyEB2YplfDIl7hoDQrIgi7UV+SBU nnKlwFd16VzveFa/4+ESLwsJIDr0gb/1LhRY5nfkwDbIBWcld8csE1XKH3GX5PkC+tQ8 k4SjL9Zvhxe7XvJE23YjvO2MBuxes1m/nRSUQZGH3DSEg889LuycvxY4i5kra4tZotSa SE7v2uaXpJf7/tS7nwVJ/sJ7VM1Vqx6SxtzFzgzNOSp8wax2RRH6ykzQbNyPtuY7FkAc ANCaeF4vHJp9qfvo1+UzzqdMt4Lf92O22kn/L6+COxovWKwRRqwImnFyVA6yAUtdHH6K wkcQ== X-Gm-Message-State: AG10YOSVIicPqGzb7kUEg5nDtHLo8O3ffIMFUXWiSb2glQyaO34c6t4AAWSYaTxagLXk9VglHvVn6m1cg6jgn8MP MIME-Version: 1.0 X-Received: by 10.129.108.146 with SMTP id h140mr241985ywc.175.1455269762353; Fri, 12 Feb 2016 01:36:02 -0800 (PST) Received: by 10.13.255.131 with HTTP; Fri, 12 Feb 2016 01:36:02 -0800 (PST) In-Reply-To: References: Date: Fri, 12 Feb 2016 12:36:02 +0300 Message-ID: Subject: Re: 'Date' and 'Timestamp' types in SQL queries From: Igor Sapego To: dev@ignite.apache.org Content-Type: multipart/alternative; boundary=001a114dcfea3cfda8052b8f6547 --001a114dcfea3cfda8052b8f6547 Content-Type: text/plain; charset=UTF-8 Ok, then I propose following solution: when user of the C++ client tries to read 'Date' value when there is an 'Timestamp' value in a stream implicit cast from 'Timestamp' to 'Date' happens and user gets his value. What do you think? Best Regards, Igor On Thu, Feb 11, 2016 at 11:25 PM, Vladimir Ozerov wrote: > I do not think we are going to change BinaryMarshaller that way. > java.util.Date is widely used and accepted data type. To the contrast, > java.sql.Date is very specific data type usually used somewhere near JDBC > layer. > > On Thu, Feb 11, 2016 at 11:06 PM, Igor Sapego > wrote: > > > I guess we should switch to java.sql.Date in BinaryMarshaller then. > > > > Best Regards, > > Igor > > > > On Thu, Feb 11, 2016 at 7:20 PM, Sergi Vladykin < > sergi.vladykin@gmail.com> > > wrote: > > > > > This is because there is no java.util.Date in SQL, we have to either > > treat > > > it as BLOB or as native SQL type Timestamp. We've chosen the latter > > > approach. > > > > > > Sergi > > > > > > 2016-02-11 18:24 GMT+03:00 Igor Sapego : > > > > > > > Sorry, I meant In our Binary marshaler we use *java.util.Date.* > > > > > > > > Best Regards, > > > > Igor > > > > > > > > On Thu, Feb 11, 2016 at 6:12 PM, Igor Sapego > > > wrote: > > > > > > > > > Ok, It seems like I have found what was causing the issue. > > > > > > > > > > In our > > > > > > > > > apache.ignite.internal.processors.queryh.h2.IgniteH2Indexing.DBTypeEnum: > > > > > > > > > > /** > > > > > * Initialize map of DB types. > > > > > */ > > > > > static { > > > > > map.put(int.class, INT); > > > > > map.put(Integer.class, INT); > > > > > map.put(boolean.class, BOOL); > > > > > map.put(Boolean.class, BOOL); > > > > > map.put(byte.class, TINYINT); > > > > > map.put(Byte.class, TINYINT); > > > > > map.put(short.class, SMALLINT); > > > > > map.put(Short.class, SMALLINT); > > > > > map.put(long.class, BIGINT); > > > > > map.put(Long.class, BIGINT); > > > > > map.put(BigDecimal.class, DECIMAL); > > > > > map.put(double.class, DOUBLE); > > > > > map.put(Double.class, DOUBLE); > > > > > map.put(float.class, REAL); > > > > > map.put(Float.class, REAL); > > > > > map.put(Time.class, TIME); > > > > > map.put(Timestamp.class, TIMESTAMP); > > > > > map.put(java.util.Date.class, TIMESTAMP); > > > > > map.put(java.sql.Date.class, DATE); > > > > > map.put(String.class, VARCHAR); > > > > > map.put(UUID.class, UUID); > > > > > map.put(byte[].class, BINARY); > > > > > } > > > > > > > > > > As I was using java.util.Date and not the java.sql.Date it was > > > translated > > > > > as TIMESTAMP > > > > > and not as DATE. Are there any particular reason for java.util.Date > > > being > > > > > treated as a > > > > > TIMESTAMP? > > > > > > > > > > In our Binary marshaler we use java.sql.Date and when I try to > change > > > > > configuration and > > > > > make the Date field to be of the type java.sql.Date I've got an > > error, > > > > > because this field value > > > > > deserialized as java.sql.Date: > > > > > > > > > > lass org.apache.ignite.IgniteCheckedException: Failed to execute > SQL > > > > query. > > > > > at > > > > > > > > > > > > > > > org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQuery(IgniteH2Indexing.java:831) > > > > > [...] > > > > > at > > > > > > > > > > > > > > > org.apache.ignite.internal.processors.platform.cache.query.PlatformAbstractQueryCursor.iterator(PlatformAbstractQueryCursor.java:134) > > > > > Caused by: org.h2.jdbc.JdbcSQLException: > > "java.lang.ClassCastException: > > > > > java.util.Date cannot be cast to java.sql.Date" > > > > > > > > > > > > > > > Best Regards, > > > > > Igor > > > > > > > > > > On Thu, Feb 11, 2016 at 12:39 PM, Vladimir Ozerov < > > > vozerov@gridgain.com> > > > > > wrote: > > > > > > > > > >> There was some changes in how .NET interoperate w/ Java on binary > > > level. > > > > >> No > > > > >> changes were made to cache or query logic. > > > > >> I performed a smoke test in Java and observed that Date field was > > > > >> correctly > > > > >> mapped to H2 date and then vice versa. > > > > >> > > > > >> Probably this is a kind of configuration problem. > > > > >> > > > > >> Vladimir. > > > > >> > > > > >> On Thu, Feb 11, 2016 at 12:41 AM, Dmitriy Setrakyan < > > > > >> dsetrakyan@apache.org> > > > > >> wrote: > > > > >> > > > > >> > I remember seeing some work done for the .NET support to provide > > > > better > > > > >> > precision for time data values. Could it be that SQL now > converts > > > > >> > everything to Timestamp because of that? > > > > >> > > > > > >> > D. > > > > >> > > > > > >> > On Wed, Feb 10, 2016 at 10:09 AM, Igor Sapego < > > isapego@gridgain.com > > > > > > > > >> > wrote: > > > > >> > > > > > >> > > Hello, > > > > >> > > > > > > >> > > Recently I've been working on implementation of the Date and > > > > Timestamp > > > > >> > > types support for C++ client [1] and I today have faced an > issue > > > > when > > > > >> I > > > > >> > was > > > > >> > > running tests with Date and SqlFieldQuery. > > > > >> > > > > > > >> > > Here is the issue. I have class that have field of type > 'Date'. > > I > > > > was > > > > >> > able > > > > >> > > to create > > > > >> > > instances of that class and put them in a cache, but when I > > tried > > > to > > > > >> > > retrieve > > > > >> > > these fields with SQL query I've got an exception. After the > > short > > > > >> debug > > > > >> > > session > > > > >> > > I have found that the values that SQL queries return are of > type > > > > >> > > 'Timestamp'. > > > > >> > > > > > > >> > > So now I'm wonder, is it an expected behavior? Because to me > it > > > > looks > > > > >> > like > > > > >> > > something that may be very confusing for a user. User knows > that > > > > >> object's > > > > >> > > field > > > > >> > > is of type 'Date' but when they try to call GetNext on > > query > > > > row > > > > >> > they > > > > >> > > get an > > > > >> > > exception. > > > > >> > > > > > > >> > > I have also tested simple caches with Date where Date is a > value > > > and > > > > >> > these > > > > >> > > tests > > > > >> > > work just fine with 'Date' returned as a result of Cache#Get() > > > > >> requests. > > > > >> > > > > > > >> > > [1] - IGNITE-2222: CPP: Implement Date and Timestamp data > types > > > > >> support > > > > >> > for > > > > >> > > binary protocol. < > > > https://issues.apache.org/jira/browse/IGNITE-2222 > > > > > > > > > >> > > Best Regards, > > > > >> > > Igor > > > > >> > > > > > > >> > > > > > >> > > > > > > > > > > > > > > > > > > > > --001a114dcfea3cfda8052b8f6547--