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 344FC200BF8 for ; Fri, 13 Jan 2017 10:23:29 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 32DD3160B3F; Fri, 13 Jan 2017 09:23:29 +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 58BAD160B32 for ; Fri, 13 Jan 2017 10:23:28 +0100 (CET) Received: (qmail 37057 invoked by uid 500); 13 Jan 2017 09:23:27 -0000 Mailing-List: contact user-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@flink.apache.org Delivered-To: mailing list user@flink.apache.org Received: (qmail 37047 invoked by uid 99); 13 Jan 2017 09:23:27 -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; Fri, 13 Jan 2017 09:23:27 +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 A95C0C04BC for ; Fri, 13 Jan 2017 09:23:26 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.879 X-Spam-Level: * X-Spam-Status: No, score=1.879 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_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=gmail.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 SoDCsh6p-z1C for ; Fri, 13 Jan 2017 09:23:24 +0000 (UTC) Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id DFC3A5FC02 for ; Fri, 13 Jan 2017 09:23:23 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id r144so61943974wme.1 for ; Fri, 13 Jan 2017 01:23:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=NK0ycuesMZrJQsqxvkRVQXmTugUcTyJoTPnTdQ7Etok=; b=spZjH9ICNNa/VtZdDpCcMbX/PtpxbNJGldOvLc6wVkWUz5/drkAJD/uJ+qDbUDHuqx VMc547DPmvto5nbuVOQ0TTM/pr/YuZU84zgZMuKZ90zzhWWqQg1SX4vgNGw9Qel8VQXX tlqJn2m6YmwOBoTuOOJeGiSpPXTLdVY3ZCxiZQcr54c6yCdP2IaTEzf9Ygo0bi5Psamg 2jEpbdZOfHkHn6tYEL6QYgSsQ2N767Y21KGDkX7cJMcnRR8Cu28bCYs/BrVHpczxetOM MABLoeXvLipg5CnPAK0JX5Z6nRVnTF2U9/4lXxVpsIBGbka3vl5ex4Yt35Tswb0AmLsf Gz3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=NK0ycuesMZrJQsqxvkRVQXmTugUcTyJoTPnTdQ7Etok=; b=TQBXnxhAph3e1f9DQ4UowUF7LsrSZ5H5xFyAJnUfsa8SRLnCClD4C/DzK7HXjx0q97 5S15nXLY6RSZit9UunamhkB3PWqG39JsB3QUG80+UQROkImnB1yO5/z9YOSDBxLiByTk 8EhPHCg+a7A39ef1Pzv8jV0oh/xprdlgJe2C56CsKUGEdbVszmlfx/fySp/BlPvfD29Z DgWevKfxRWVEvpmQg1svBjMoS5zlBc2WiNKdEhbDMzoVx0xaTFOCLHScua1Naa4FtYRT kqAvUcXqWO0QZApI7JrxBB6bfBSSIiuPVWWMuP7o0B4krGLv9ezz2VVDv3JCefUT0K4u /ltg== X-Gm-Message-State: AIkVDXJJYRYsu9gGknEIA8WGHEuGsa1hNto4LzUShoWolw+BXLaNpTKTFkUnexrj+iRgmS2ckfTJpk9o3uiOIA== X-Received: by 10.223.163.87 with SMTP id d23mr10795447wrb.87.1484299399615; Fri, 13 Jan 2017 01:23:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.162.129 with HTTP; Fri, 13 Jan 2017 01:22:49 -0800 (PST) In-Reply-To: References: From: Fabian Hueske Date: Fri, 13 Jan 2017 10:22:49 +0100 Message-ID: Subject: Re: the attribute order in sql 'select * from...' To: user@flink.apache.org Content-Type: multipart/alternative; boundary=f403045f1c50745b020545f66228 archived-at: Fri, 13 Jan 2017 09:23:29 -0000 --f403045f1c50745b020545f66228 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Yuhong, I assume that OrderA is a table of POJO objects and you are expecting the order of the attribute to be as the order in which the fields of the POJO are defined in the source code. Flink accepts fields which are either public members or accessible via a getter and setter. This makes it difficult to automatically define an order, esp. if some fields use getter and setter or public fields. Would the order depend on the field (which might not exist in case of getter/setter) or setter or getter methods (which might also not exist). I'm also not sure if it is possible to extract the line number of a method or field via reflection. Best, Fabian 2017-01-13 9:54 GMT+01:00 Hongyuhong : > Hi, > > I=E2=80=99m now using streaming sql, And I have the sql like > > select * FROM OrderA where user > 2 > > the OrderA has 3 attr (user, product, amount) > > and I expect the result is as the order like input, but it has been sorte= d > by attr name, > > and I found the order has already been sorted when call addSource, > > What is the purpose of doing so?cause it=E2=80=99s a little not meet our > requirements. > > > > Thanks very much. > > > > > > public PojoTypeInfo(Class typeClass, List fields) { > > super(typeClass); > > > > checkArgument(Modifier.isPublic(typeClass. > getModifiers()), > > "POJO %s is not public", typeClass); > > > > this.fields =3D fields.toArray(new > PojoField[fields.size()]); > > > > Arrays.sort(this.fields, new Comparator() { > > @Override > > public int compare(PojoField o1, PojoField o2= ) > { > > return o1.getField().getName(). > compareTo(o2.getField().getName()); > > } > > }); > > > > > > Best, > > Yuhong > --f403045f1c50745b020545f66228 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Yuhong,

I assume that OrderA is = a table of POJO objects and you are expecting the order of the attribute to= be as the order in which the fields of the POJO are defined in the source = code.

Flink accepts fields which are either public members or access= ible via a getter and setter.
This makes it difficult to auto= matically define an order, esp. if some fields use getter and setter or pub= lic fields. Would the order depend on the field (which might not exist in c= ase of getter/setter) or setter or getter methods (which might also not exi= st).
I'm also not sure if it is possible to extract the l= ine number of a method or field via reflection.

Best, Fab= ian



2017-01-13 9:54 GMT+01:00 Hongyuhong <hongyuhong= @huawei.com>:

Hi,

I=E2=80=99m now using streaming= sql, And I have the sql like

select *=C2=A0 FROM OrderA wher= e user > 2

the OrderA has 3 attr (user, pr= oduct, amount)

and I expect the result is as t= he order like input, but it has been sorted by attr name,

and I found the order has alrea= dy been sorted when call addSource,

What is the purpose of doing so= ?cause it=E2=80=99s a little not meet our requirements.

=C2=A0

Thanks very much.=

=C2=A0

=C2=A0

public PojoTypeInfo(Class<T&= gt; typeClass, List<PojoField> fields) {

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 super(typeClass);

=C2=A0

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 checkArgument(Modifier.isPublic(typeClass.getModifiers()),=

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "POJO %s is not public"= , typeClass);

=C2=A0

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 this.fields =3D fields.toArray(new PojoField[fields.size()]);=

=C2=A0

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 Arrays.sort(this.fields, new Comparator<PojoField>() {<= /u>

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 @Override<= u>

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 public int compar= e(PojoField o1, PojoField o2) {

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return o1.getField().getName().compareTo(o2.getField().getName());

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 });

=C2=A0

=C2=A0

Best,

Yuhong


--f403045f1c50745b020545f66228--