You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by "weibin0516 (JIRA)" <ji...@apache.org> on 2019/07/03 02:41:00 UTC

[jira] [Created] (KYLIN-4069) HivePushDownConverter.doConvert will change sql semantics in some scenarios

weibin0516 created KYLIN-4069:
---------------------------------

             Summary: HivePushDownConverter.doConvert will change sql semantics in some scenarios
                 Key: KYLIN-4069
                 URL: https://issues.apache.org/jira/browse/KYLIN-4069
             Project: Kylin
          Issue Type: Bug
          Components: Query Engine
    Affects Versions: v2.6.2
            Reporter: weibin0516
            Assignee: weibin0516



HivePushDownConverter.doConvert source code is as follows:

    
{code:java}
public static String doConvert(String originStr, boolean isPrepare) {
        // Step1.Replace " with `
        String convertedSql = replaceString(originStr, "\"", "`");

        // Step2.Replace extract functions
        convertedSql = extractReplace(convertedSql);

        // Step3.Replace cast type string
        convertedSql = castReplace(convertedSql);

        // Step4.Replace sub query
        convertedSql = subqueryReplace(convertedSql);

        // Step5.Replace char_length with length
        convertedSql = replaceString(convertedSql, "CHAR_LENGTH", "LENGTH");
        convertedSql = replaceString(convertedSql, "char_length", "length");

        // Step6.Replace "||" with concat
        convertedSql = concatReplace(convertedSql);

        // Step7.Add quote for interval in timestampadd
        convertedSql = timestampAddDiffReplace(convertedSql);

        // Step8.Replace integer with int
        convertedSql = replaceString(convertedSql, "INTEGER", "INT");
        convertedSql = replaceString(convertedSql, "integer", "int");

        // Step9.Add limit 1 for prepare select sql to speed up
        if (isPrepare) {
            convertedSql = addLimit(convertedSql);
        }

        return convertedSql;
    }
{code}


It is not advisable to directly replace the sql text. The following example will convert sql to another error sql:

{code:sql}
SELECT "CHAR_LENGTH" FROM datasource.a
{code}

will convert to 

{code:sql}
SELECT `LENGTH` FROM datasource.a
{code}


Every use of replaceString in doConvert will cause such problems.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)