Conversation
|
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. DetailsReviewer can indicate their review by submitting an approval review. |
|
@ywqzzy: PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
| c_res->getChars(), | ||
| c_res->getOffsets()); | ||
| else | ||
| throw Exception("Illegal columns " |
| c_res->getChars(), | ||
| c_res->getOffsets()); | ||
| else | ||
| throw Exception("Illegal columns " |
| class FunctionTiDBLeastGreatest : public IFunction | ||
| { | ||
| public: | ||
| static constexpr auto name = kind == LeastGreatest::Least ? "tidbLeast" : "tidbGreatest"; |
There was a problem hiding this comment.
how about `` static constexpr auto name = kind::name`
| DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override | ||
| { | ||
| if (arguments.size() < 2) | ||
| throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " + toString(arguments.size()) |
| size_t num_arguments = arguments.size(); | ||
| if (num_arguments < 2) | ||
| { | ||
| throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " |
| DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override | ||
| { | ||
| if (arguments.size() < 2) | ||
| throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " + toString(arguments.size()) |
| size_t num_arguments = arguments.size(); | ||
| if (num_arguments < 2) | ||
| { | ||
| throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " |
| return data->compareAt(0, 0, *static_cast<const ColumnConst &>(rhs).data, nan_direction_hint); | ||
| } | ||
|
|
||
| int compareAtWithCollation(size_t, size_t m, const IColumn & rhs_, int null_direction_hint, const ICollator & collator) const override |
There was a problem hiding this comment.
how about int int compareAt(size_t, size_t, const IColumn & rhs, int nan_direction_hint, , const ICollator * collator = nullptr) const override
There was a problem hiding this comment.
maybe i can create another pr to make the interface clean in all related files.
| else | ||
| cmp_result = converted_columns[arg]->compareAt(row_num, row_num, *converted_columns[best_arg], 1); | ||
|
|
||
| if constexpr (kind == LeastGreatest::Least) |
There was a problem hiding this comment.
how about if (kind::xxx(cmp_result )) { best_arg = arg; }
| DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override | ||
| { | ||
| if (arguments.size() < 2) | ||
| throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " + toString(arguments.size()) |
|
|
||
| TiDB::TiDBCollatorPtr getCollatorFromFieldType(const tipb::FieldType & field_type) | ||
| { | ||
| std::cout << "field type collate: " << field_type.collate() << std::endl; |
There was a problem hiding this comment.
| std::cout << "field type collate: " << field_type.collate() << std::endl; |
| for (const auto & child : expr.children()) | ||
| { | ||
| String name = getActions(child, actions); | ||
| std::cout << "name: " << name << std::endl; |
There was a problem hiding this comment.
clean up these debug lines
| ExpressionActionsPtr & actions) | ||
| { | ||
| const String & func_name = getFunctionName(expr); | ||
| std::cout << "func_name: " << func_name << std::endl; |
| const TiDB::TiDBCollatorPtr & collator) | ||
| { | ||
| String result_name = genFuncString(func_name, arg_names, {collator}); | ||
| std::cout << "result name: " << result_name << std::endl; |
|
|
||
| struct CompareDecimalInferer | ||
| { | ||
| static inline void infer(PrecType left_prec, ScaleType left_scale, PrecType right_prec, ScaleType right_scale, PrecType & result_prec, ScaleType & result_scale) |
There was a problem hiding this comment.
| static inline void infer(PrecType left_prec, ScaleType left_scale, PrecType right_prec, ScaleType right_scale, PrecType & result_prec, ScaleType & result_scale) | |
| static std::tuple<PrecType, ScaleType> infer(PrecType left_prec, ScaleType left_scale, PrecType right_prec, ScaleType right_scale) |
what is it used for?
| {} | ||
|
|
||
| String toString(int fsp) const; | ||
| int fsp; |
There was a problem hiding this comment.
could you explain why MyDateTime need fsp and why not put it into the base class?
There was a problem hiding this comment.
ASSERT_COLUMN_EQ(
createColumn<Nullable<String>>({"2020-10-20 00:00:00"}),
executeFunction(
func_name,
createColumn<Nullable<String>>({"2021-12-28 11:19:09"}),
createColumn<Nullable<String>>({"2020-10-20"})));
Without fsp, the result will be "2020-10-20", which is inconsistent with MYSQL and TIDB, the follwing getFsp() function was added to align with TIDB
| return idx; | ||
| } | ||
|
|
||
| int getFsp(const String & s) |
There was a problem hiding this comment.
which format is s expected to be?
| template <typename A, typename B> | ||
| struct ResultOfTiDBLeast | ||
| { | ||
| static constexpr auto result_size = std::max(actual_size_v<A>, actual_size_v<B>); |
There was a problem hiding this comment.
to align with TiDB, least/greatest for integers should always return Int64 or UInt64.
| typename ResultOfIf<A, B>::Type>; | ||
|
|
||
| template <typename A, typename B> | ||
| constexpr bool TiDBLeastGreatestSpecialCase |
There was a problem hiding this comment.
It should be a type inferer and let the users get the return type of least/greatest like:
using ReturnType = TiDBLeastGreatestReturnTypeInferer<true /*least*/, A, B>;
What problem does this PR solve?
Issue Number: close #xxx
Problem Summary:
What is changed and how it works?
Proposal: xxx
What's Changed:
Related changes
pingcap/docs/pingcap/docs-cn:Check List
Tests
Side effects
Release note