Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

least/greatest function for string #6662

Merged
merged 23 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dbms/src/Flash/Coprocessor/DAGUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 PingCAP, Ltd.
// Copyright 2023 PingCAP, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -162,13 +162,13 @@ const std::unordered_map<tipb::ScalarFuncSig, String> scalar_func_map({

{tipb::ScalarFuncSig::GreatestInt, "tidbGreatest"},
{tipb::ScalarFuncSig::GreatestReal, "tidbGreatest"},
{tipb::ScalarFuncSig::GreatestString, "greatest"},
{tipb::ScalarFuncSig::GreatestString, "tidbGreatestString"},
{tipb::ScalarFuncSig::GreatestDecimal, "greatest"},
{tipb::ScalarFuncSig::GreatestTime, "greatest"},

{tipb::ScalarFuncSig::LeastInt, "tidbLeast"},
{tipb::ScalarFuncSig::LeastReal, "tidbLeast"},
{tipb::ScalarFuncSig::LeastString, "least"},
{tipb::ScalarFuncSig::LeastString, "tidbLeastString"},
ywqzzy marked this conversation as resolved.
Show resolved Hide resolved
{tipb::ScalarFuncSig::LeastDecimal, "least"},
{tipb::ScalarFuncSig::LeastTime, "least"},

Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Functions/FunctionsComparison.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 PingCAP, Ltd.
// Copyright 2023 PingCAP, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
18 changes: 9 additions & 9 deletions dbms/src/Functions/FunctionsConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ struct ConvertToDecimalImpl
}
else
{
if (const ColumnVector<FromFieldType> * col_from
if (const auto * col_from
= checkAndGetColumn<ColumnVector<FromFieldType>>(block.getByPosition(arguments[0]).column.get()))
{
auto col_to = ColumnDecimal<ToFieldType>::create(0, scale);
Expand Down Expand Up @@ -245,7 +245,7 @@ struct ConvertToDecimalImpl<DataTypeString, Name, ToDataType>

const IDataType & data_type_to = *block.getByPosition(result).type;

if (const ColumnString * col_from_string = checkAndGetColumn<ColumnString>(&col_from))
if (const auto * col_from_string = checkAndGetColumn<ColumnString>(&col_from))
{
auto res = data_type_to.createColumn();

Expand Down Expand Up @@ -758,8 +758,8 @@ struct ConvertThroughParsing
}

const IColumn * col_from = block.getByPosition(arguments[0]).column.get();
const ColumnString * col_from_string = checkAndGetColumn<ColumnString>(col_from);
const ColumnFixedString * col_from_fixed_string = checkAndGetColumn<ColumnFixedString>(col_from);
const auto * col_from_string = checkAndGetColumn<ColumnString>(col_from);
const auto * col_from_fixed_string = checkAndGetColumn<ColumnFixedString>(col_from);

if (std::is_same_v<FromDataType, DataTypeString> && !col_from_string)
throw Exception("Illegal column " + col_from->getName()
Expand Down Expand Up @@ -880,7 +880,7 @@ struct ConvertImplGenericFromString

const IDataType & data_type_to = *block.getByPosition(result).type;

if (const ColumnString * col_from_string = checkAndGetColumn<ColumnString>(&col_from))
if (const auto * col_from_string = checkAndGetColumn<ColumnString>(&col_from))
{
auto res = data_type_to.createColumn();

Expand Down Expand Up @@ -947,7 +947,7 @@ struct ConvertImpl<DataTypeFixedString, DataTypeString, Name>
{
static void execute(Block & block, const ColumnNumbers & arguments, size_t result)
{
if (const ColumnFixedString * col_from = checkAndGetColumn<ColumnFixedString>(block.getByPosition(arguments[0]).column.get()))
if (const auto * col_from = checkAndGetColumn<ColumnFixedString>(block.getByPosition(arguments[0]).column.get()))
{
auto col_to = ColumnString::create();

Expand Down Expand Up @@ -1754,7 +1754,7 @@ class FunctionDateFormat : public IFunction
class FunctionGetFormat : public IFunction
{
private:
static String get_format(const StringRef & time_type, const StringRef & location)
static String getFormat(const StringRef & time_type, const StringRef & location)
{
if (time_type == "DATE")
{
Expand Down Expand Up @@ -1850,7 +1850,7 @@ class FunctionGetFormat : public IFunction
for (size_t i = 0; i < size; ++i)
{
const auto & location = location_col->getDataAt(i);
const auto & result = get_format(StringRef(time_type), location);
const auto & result = getFormat(StringRef(time_type), location);
write_buffer.write(result.c_str(), result.size());
writeChar(0, write_buffer);
offsets_to[i] = write_buffer.count();
Expand Down Expand Up @@ -2615,7 +2615,7 @@ class FunctionCast final : public IFunctionBase
const size_t result) {
const auto & array_arg = block.getByPosition(arguments.front());

if (const ColumnArray * col_array = checkAndGetColumn<ColumnArray>(array_arg.column.get()))
if (const auto * col_array = checkAndGetColumn<ColumnArray>(array_arg.column.get()))
{
/// create block for converting nested column containing original and result columns
Block nested_block{
Expand Down
Loading