kylin-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "peng.jianhua (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (KYLIN-3119) Fix a few bugs in function 'massageSql' of 'QueryUtil.java'
Date Wed, 20 Dec 2017 08:02:00 GMT

     [ https://issues.apache.org/jira/browse/KYLIN-3119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

peng.jianhua updated KYLIN-3119:
--------------------------------
    Description: 
    public static String massageSql(String sql, String project, int limit, int offset, String
defaultSchema) {
        sql = sql.trim();
        sql = sql.replace("\r", " ").replace("\n", System.getProperty("line.separator"));
        KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();

        while (sql.endsWith(";"))
            sql = sql.substring(0, sql.length() - 1);

        if (limit > 0 && !sql.toLowerCase().contains("limit")) {
            sql += ("\nLIMIT " + limit);
        }

        if (offset > 0 && !sql.toLowerCase().contains("offset")) {
            sql += ("\nOFFSET " + offset);
        }

        // https://issues.apache.org/jira/browse/KYLIN-2649
        if (kylinConfig.getForceLimit() > 0 && !sql.toLowerCase().contains("limit")
                && sql.toLowerCase().contains("*")) {
            sql += ("\nLIMIT " + kylinConfig.getForceLimit());
        }

        // customizable SQL transformation
        if (queryTransformers == null) {
            initQueryTransformers();
        }
        for (IQueryTransformer t : queryTransformers) {
            sql = t.transform(sql, project, defaultSchema);
        }
        return sql;
    }

> Fix a few bugs in 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
>
>     public static String massageSql(String sql, String project, int limit, int offset,
String defaultSchema) {
>         sql = sql.trim();
>         sql = sql.replace("\r", " ").replace("\n", System.getProperty("line.separator"));
>         KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
>         while (sql.endsWith(";"))
>             sql = sql.substring(0, sql.length() - 1);
>         if (limit > 0 && !sql.toLowerCase().contains("limit")) {
>             sql += ("\nLIMIT " + limit);
>         }
>         if (offset > 0 && !sql.toLowerCase().contains("offset")) {
>             sql += ("\nOFFSET " + offset);
>         }
>         // https://issues.apache.org/jira/browse/KYLIN-2649
>         if (kylinConfig.getForceLimit() > 0 && !sql.toLowerCase().contains("limit")
>                 && sql.toLowerCase().contains("*")) {
>             sql += ("\nLIMIT " + kylinConfig.getForceLimit());
>         }
>         // customizable SQL transformation
>         if (queryTransformers == null) {
>             initQueryTransformers();
>         }
>         for (IQueryTransformer t : queryTransformers) {
>             sql = t.transform(sql, project, defaultSchema);
>         }
>         return sql;
>     }



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message