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 331DB200D5D for ; Wed, 20 Dec 2017 09:43:04 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 319BD160C2B; Wed, 20 Dec 2017 08:43:04 +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 50EF2160C0A for ; Wed, 20 Dec 2017 09:43:03 +0100 (CET) Received: (qmail 66559 invoked by uid 500); 20 Dec 2017 08:43:02 -0000 Mailing-List: contact issues-help@kylin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kylin.apache.org Delivered-To: mailing list issues@kylin.apache.org Received: (qmail 66550 invoked by uid 99); 20 Dec 2017 08:43:02 -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, 20 Dec 2017 08:43:02 +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 13AE4C4583 for ; Wed, 20 Dec 2017 08:43:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.011 X-Spam-Level: X-Spam-Status: No, score=-100.011 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-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 tAyZEL6Ru9pC for ; Wed, 20 Dec 2017 08:43:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id BFD915F1E7 for ; Wed, 20 Dec 2017 08:43:00 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 46ED6E012B for ; Wed, 20 Dec 2017 08:43:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 0BE18240DA for ; Wed, 20 Dec 2017 08:43:00 +0000 (UTC) Date: Wed, 20 Dec 2017 08:43:00 +0000 (UTC) From: "peng.jianhua (JIRA)" To: issues@kylin.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (KYLIN-3119) A few bugs in the function 'massageSql' of 'QueryUtil.java' MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 20 Dec 2017 08:43:04 -0000 [ https://issues.apache.org/jira/browse/KYLIN-3119?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:all-tabpanel ] peng.jianhua updated KYLIN-3119: -------------------------------- Description:=20 in the function 'massageSql' of 'QueryUtil.java',there are a few bugs: 01: {code:java} while (sql.endsWith(";")) sql =3D sql.substring(0, sql.length() - 1); {code} if the sql end with ';' and after the ';' still has comments,will be error.= Because the sql will add ("\nLIMIT " + limit) at the end. 02: {code:java} if (limit > 0 && !sql.toLowerCase().contains("limit")) { sql +=3D ("\nLIMIT " + limit); } if (offset > 0 && !sql.toLowerCase().contains("offset")) { sql +=3D ("\nOFFSET " + offset); } {code} if the sql already has word 'limit' in it,such as Alias,Subquery,Comments,t= he =E2=80=98limit=E2=80=99 in the Input box will be invalid. for example,the sql has subquery,and there is 'limit' in subquery. {code:java} select KYLIN_SALES.PART_DT, count(KYLIN_SALES.PRICE) from KYLIN_SALES inner join (select ACCOUNT_ID, ACCOUNT_BUYER_LEVEL from KYLIN_ACCOUNT where= ACCOUNT_COUNTRY =3D 'US' limit 10000) as TT on KYLIN_SALES.BUYER_ID =3D TT.ACCOUNT_ID group by KYLIN_SALES.PART_DT {code} the =E2=80=98limit=E2=80=99 in the Input box will be invalid.please refer t= o 01.png and 02.png. 03: {code:java} // https://issues.apache.org/jira/browse/KYLIN-2649 if (kylinConfig.getForceLimit() > 0 && !sql.toLowerCase().contains(= "limit") && sql.toLowerCase().contains("*")) { sql +=3D ("\nLIMIT " + kylinConfig.getForceLimit()); } {code} Because KYLIN-2649 is still unresolved,so I didn't change the code,but it = has same 'limit' word bugs like above. And there are some situations that the sql contains \*,such as {code:java}c= ount(*),kylin_sales.*{code} it seems improperly to deal with the sql just use {code:java} sql.toLowerCase().contains("*") {code} it seems improperly to deal with the sql just use {code:java} sql.toLowerCase().contains("*") {code} was: in the function 'massageSql' of 'QueryUtil.java',there are a few bugs: 01: {code:java} while (sql.endsWith(";")) sql =3D sql.substring(0, sql.length() - 1); {code} if the sql end with ';' and after the ';' still has comments,will be error.= Because the sql will add ("\nLIMIT " + limit) at the end. 02: {code:java} if (limit > 0 && !sql.toLowerCase().contains("limit")) { sql +=3D ("\nLIMIT " + limit); } if (offset > 0 && !sql.toLowerCase().contains("offset")) { sql +=3D ("\nOFFSET " + offset); } {code} if the sql already has word 'limit' in it,such as Alias,Subquery,Comments,t= he =E2=80=98limit=E2=80=99 in the Input box will be invalid. for example,the sql has subquery,and there is 'limit' in subquery. {code:java} select KYLIN_SALES.PART_DT, count(KYLIN_SALES.PRICE) from KYLIN_SALES inner join (select ACCOUNT_ID, ACCOUNT_BUYER_LEVEL from KYLIN_ACCOUNT where= ACCOUNT_COUNTRY =3D 'US' limit 10000) as TT on KYLIN_SALES.BUYER_ID =3D TT.ACCOUNT_ID group by KYLIN_SALES.PART_DT {code} the =E2=80=98limit=E2=80=99 in the Input box will be invalid.please refer t= o 01.png and 02.png. 03: {code:java} // https://issues.apache.org/jira/browse/KYLIN-2649 if (kylinConfig.getForceLimit() > 0 && !sql.toLowerCase().contains(= "limit") && sql.toLowerCase().contains("*")) { sql +=3D ("\nLIMIT " + kylinConfig.getForceLimit()); } {code} Because KYLIN-2649 is still unresolved,so I didn't change the code,but it = has same 'limit' word bugs like above. And there are some situations that the sql contains \*,such as {code:java}c= ount(*),kylin_sales.*{code} it seems improperly to deal with the sql just use {code:java} sql.toLowerCase().contains("*") {code} > A few bugs in the function 'massageSql' of 'QueryUtil.java' > ----------------------------------------------------------- > > Key: KYLIN-3119 > URL: https://issues.apache.org/jira/browse/KYLIN-3119 > Project: Kylin > Issue Type: Bug > Reporter: peng.jianhua > Assignee: peng.jianhua > > in the function 'massageSql' of 'QueryUtil.java',there are a few bugs: > 01: > {code:java} > while (sql.endsWith(";")) > sql =3D sql.substring(0, sql.length() - 1); > {code} > if the sql end with ';' and after the ';' still has comments,will be erro= r.Because the sql will add ("\nLIMIT " + limit) at the end. > 02: > {code:java} > if (limit > 0 && !sql.toLowerCase().contains("limit")) { > sql +=3D ("\nLIMIT " + limit); > } > if (offset > 0 && !sql.toLowerCase().contains("offset")) { > sql +=3D ("\nOFFSET " + offset); > } > {code} > if the sql already has word 'limit' in it,such as Alias,Subquery,Comments= ,the =E2=80=98limit=E2=80=99 in the Input box will be invalid. > for example,the sql has subquery,and there is 'limit' in subquery. > {code:java} > select KYLIN_SALES.PART_DT, count(KYLIN_SALES.PRICE) > from KYLIN_SALES > inner join (select ACCOUNT_ID, ACCOUNT_BUYER_LEVEL from KYLIN_ACCOUNT whe= re ACCOUNT_COUNTRY =3D 'US' limit 10000) as TT > on KYLIN_SALES.BUYER_ID =3D TT.ACCOUNT_ID > group by KYLIN_SALES.PART_DT > {code} > the =E2=80=98limit=E2=80=99 in the Input box will be invalid.please refer= to 01.png and 02.png. > 03: > {code:java} > // https://issues.apache.org/jira/browse/KYLIN-2649 > if (kylinConfig.getForceLimit() > 0 && !sql.toLowerCase().contain= s("limit") > && sql.toLowerCase().contains("*")) { > sql +=3D ("\nLIMIT " + kylinConfig.getForceLimit()); > } > {code} > Because KYLIN-2649 is still unresolved,so I didn't change the code,but i= t has same 'limit' word bugs like above. > And there are some situations that the sql contains \*,such as {code:java= }count(*),kylin_sales.*{code} > it seems improperly to deal with the sql just use {code:java} > sql.toLowerCase().contains("*") > {code} > it seems improperly to deal with the sql just use {code:java} > sql.toLowerCase().contains("*") > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)