JingDas commented on code in PR #21855: URL: https://github.com/apache/doris/pull/21855#discussion_r1292876646
########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilderAssistant.java: ########## @@ -0,0 +1,111 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.parser; + +import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral; +import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral; +import org.apache.doris.nereids.trees.expressions.literal.LargeIntLiteral; +import org.apache.doris.nereids.trees.expressions.literal.Literal; +import org.apache.doris.nereids.trees.expressions.literal.SmallIntLiteral; +import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral; +import org.apache.doris.nereids.trees.plans.logical.LogicalCheckPolicy; +import org.apache.doris.nereids.trees.plans.logical.LogicalPlan; + +import java.math.BigInteger; + +/** + * Logical plan builder assistant for buildIn dialect and other dialect. + * The same logical in {@link org.apache.doris.nereids.parser.LogicalPlanBuilder} + * and {@link org.apache.doris.nereids.parser.trino.LogicalPlanTrinoBuilder} can be + * extracted to here. + */ +public class LogicalPlanBuilderAssistant { + + private LogicalPlanBuilderAssistant() { + } + + /** + * EscapeBackSlash such \n, \t + */ + public static String escapeBackSlash(String str) { + StringBuilder sb = new StringBuilder(); + int strLen = str.length(); + for (int i = 0; i < strLen; ++i) { + char c = str.charAt(i); + if (c == '\\' && (i + 1) < strLen) { + switch (str.charAt(i + 1)) { + case 'n': + sb.append('\n'); + break; + case 't': + sb.append('\t'); + break; + case 'r': + sb.append('\r'); + break; + case 'b': + sb.append('\b'); + break; + case '0': + sb.append('\0'); // Ascii null + break; + case 'Z': // ^Z must be escaped on Win32 + sb.append('\032'); + break; + case '_': + case '%': + sb.append('\\'); // remember prefix for wildcard + sb.append(str.charAt(i + 1)); + break; + default: + sb.append(str.charAt(i + 1)); + break; + } + i++; + } else { + sb.append(c); + } + } + return sb.toString(); + } + + /** + * Handle Integer literal by BigInteger. + */ + public static Literal handleIntegerLiteral(String value) { Review Comment: yeah, I think the logic of `handleInteger`can be consistent to doris. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
