// Copyright 2023 PingCAP, Inc. // // Licensed 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. #pragma once #include #include #include #include namespace DB { class Context; class IDataType; /** Evaluate constant expression and its type. * Used in rare cases - for elements of set for IN, for data to INSERT. * Quite suboptimal. */ std::pair> evaluateConstantExpression( const ASTPtr & node, const Context & context); /** Evaluate constant expression * and returns ASTLiteral with its value. */ ASTPtr evaluateConstantExpressionAsLiteral(const ASTPtr & node, const Context & context); /** Evaluate constant expression * and returns ASTLiteral with its value. * Also, if AST is identifier, then return string literal with its name. * Useful in places where some name may be specified as identifier, or as result of a constant expression. */ ASTPtr evaluateConstantExpressionOrIdentifierAsLiteral(const ASTPtr & node, const Context & context); } // namespace DB