Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
v2.6.2
-
None
-
None
Description
HivePushDownConverter.doConvert source code is as follows:
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; }
It is not advisable to directly replace the sql text. The following example will convert sql to another error sql:
SELECT "CHAR_LENGTH" FROM datasource.a
will convert to
SELECT `LENGTH` FROM datasource.a
Every use of replaceString in doConvert will cause such problems.