From 95c5ff371895d5f9cb4c703f1351b1bed81c1c00 Mon Sep 17 00:00:00 2001 From: kothiga Date: Thu, 7 Mar 2024 10:55:53 -0800 Subject: [PATCH] Kusto-phase3: rebase v24.2.1.2248-stable fixes --- src/Common/IntervalKind.h | 8 ++++---- src/Functions/FunctionsConversion.h | 2 +- src/Functions/Kusto/KqlRange.cpp | 2 +- src/Functions/Kusto/kqlDateTime.cpp | 4 ++-- src/Functions/Kusto/kqlIndexOfRegex.cpp | 10 +--------- src/Functions/Kusto/kqlToTimespan.cpp | 2 +- src/Functions/dateTime64Diff.cpp | 2 +- src/Processors/QueryPlan/PartsSplitter.cpp | 6 +++--- src/Storages/System/StorageSystemSchema.cpp | 20 ++++++++++--------- src/Storages/System/StorageSystemSchema.h | 3 +-- src/TableFunctions/TableFunctionGetSchema.cpp | 2 +- 11 files changed, 27 insertions(+), 34 deletions(-) diff --git a/src/Common/IntervalKind.h b/src/Common/IntervalKind.h index d77a39cb9fa8..2842de68f546 100644 --- a/src/Common/IntervalKind.h +++ b/src/Common/IntervalKind.h @@ -42,7 +42,7 @@ struct IntervalKind Float64 toSeconds() const; /// Chooses an interval kind based on number of seconds. - /// For example, `IntervalKind::fromAvgSeconds(3600)` returns `IntervalKind::Hour`. + /// For example, `IntervalKind::fromAvgSeconds(3600)` returns `IntervalKind::Kind::Hour`. static IntervalKind fromAvgSeconds(Int64 num_seconds); /// Returns whether IntervalKind has a fixed number of seconds (e.g. Day) or non-fixed(e.g. Month) @@ -54,16 +54,16 @@ struct IntervalKind const char * toLowercasedKeyword() const; /// Returns the string which can be passed to the `unit` parameter of the dateDiff() function. - /// For example, `IntervalKind{IntervalKind::Day}.getDateDiffParameter()` returns "day". + /// For example, `IntervalKind{IntervalKind::Kind::Day}.getDateDiffParameter()` returns "day". const char * toDateDiffUnit() const; /// Returns the name of the function converting a number to the interval data type. - /// For example, `IntervalKind{IntervalKind::Day}.getToIntervalDataTypeFunctionName()` + /// For example, `IntervalKind{IntervalKind::Kind::Day}.getToIntervalDataTypeFunctionName()` /// returns "toIntervalDay". const char * toNameOfFunctionToIntervalDataType() const; /// Returns the name of the function extracting time part from a date or a time. - /// For example, `IntervalKind{IntervalKind::Day}.getExtractTimePartFunctionName()` + /// For example, `IntervalKind{IntervalKind::Kind::Day}.getExtractTimePartFunctionName()` /// returns "toDayOfMonth". const char * toNameOfFunctionExtractTimePart() const; diff --git a/src/Functions/FunctionsConversion.h b/src/Functions/FunctionsConversion.h index 11d65400f15b..0f693b672cbe 100644 --- a/src/Functions/FunctionsConversion.h +++ b/src/Functions/FunctionsConversion.h @@ -3316,7 +3316,7 @@ class FunctionCast final : public FunctionCastBase switch (interval_kind) { #define DECLARE_CASE(NAME) \ - case IntervalKind::NAME: \ + case IntervalKind::Kind::NAME: \ return FunctionToInterval##NAME::create(); FOR_EACH_INTERVAL_KIND(DECLARE_CASE) #undef DECLARE_CASE diff --git a/src/Functions/Kusto/KqlRange.cpp b/src/Functions/Kusto/KqlRange.cpp index 25cffd9c2258..0fcb00f58b63 100644 --- a/src/Functions/Kusto/KqlRange.cpp +++ b/src/Functions/Kusto/KqlRange.cpp @@ -809,7 +809,7 @@ class FunctionKqlRange : public IFunction total_values = total_elements; } - auto out = ColumnArray::create(std::make_shared(IntervalKind::Nanosecond)->createColumn()); + auto out = ColumnArray::create(std::make_shared(IntervalKind::Kind::Nanosecond)->createColumn()); IColumn & out_data = out->getData(); IColumn::Offsets & out_offsets = out->getOffsets(); diff --git a/src/Functions/Kusto/kqlDateTime.cpp b/src/Functions/Kusto/kqlDateTime.cpp index a4b7beb5ec8a..09b0eaf999a3 100644 --- a/src/Functions/Kusto/kqlDateTime.cpp +++ b/src/Functions/Kusto/kqlDateTime.cpp @@ -95,11 +95,11 @@ ColumnPtr FunctionKqlDateTime::executeImpl( const ColumnsWithTypeAndName addition_args{ asArgument(converted, "converted"), - createConstColumnWithTypeAndName(50, "interval_50", IntervalKind::Nanosecond)}; + createConstColumnWithTypeAndName(50, "interval_50", IntervalKind::Kind::Nanosecond)}; const auto sum = executeFunctionCall(context, "plus", addition_args, input_rows_count); const ColumnsWithTypeAndName to_start_of_interval_args{ - asArgument(sum, "sum"), createConstColumnWithTypeAndName(100, "interval_100", IntervalKind::Nanosecond)}; + asArgument(sum, "sum"), createConstColumnWithTypeAndName(100, "interval_100", IntervalKind::Kind::Nanosecond)}; const auto [rounded_column, _] = executeFunctionCall(context, "toStartOfInterval", to_start_of_interval_args, input_rows_count); return wrapInNullable(rounded_column, conversion_args, result_type, input_rows_count); diff --git a/src/Functions/Kusto/kqlIndexOfRegex.cpp b/src/Functions/Kusto/kqlIndexOfRegex.cpp index 371ad2d2dc8c..8bf209a4e2dc 100644 --- a/src/Functions/Kusto/kqlIndexOfRegex.cpp +++ b/src/Functions/Kusto/kqlIndexOfRegex.cpp @@ -1,21 +1,13 @@ #include #include #include +#include #include #include #include #include #include -#ifdef __clang__ -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" -#endif -#include -#ifdef __clang__ -# pragma clang diagnostic pop -#endif - namespace DB::ErrorCodes { extern const int CANNOT_COMPILE_REGEXP; diff --git a/src/Functions/Kusto/kqlToTimespan.cpp b/src/Functions/Kusto/kqlToTimespan.cpp index 39923de9d187..5d59ffe2d15c 100644 --- a/src/Functions/Kusto/kqlToTimespan.cpp +++ b/src/Functions/Kusto/kqlToTimespan.cpp @@ -79,7 +79,7 @@ ColumnPtr FunctionKqlToTimespan::executeImpl( DataTypePtr FunctionKqlToTimespan::getReturnTypeImpl(const DataTypes &) const { - return makeNullable(std::make_shared(IntervalKind::Nanosecond)); + return makeNullable(std::make_shared(IntervalKind::Kind::Nanosecond)); } REGISTER_FUNCTION(KqlToTimespan) diff --git a/src/Functions/dateTime64Diff.cpp b/src/Functions/dateTime64Diff.cpp index f03bd189d042..a4c378b0e457 100644 --- a/src/Functions/dateTime64Diff.cpp +++ b/src/Functions/dateTime64Diff.cpp @@ -92,7 +92,7 @@ DataTypePtr FunctionDateTime64Diff::getReturnTypeImpl(const DataTypes & argument rhs->getName(), getName()); - return std::make_shared(IntervalKind::Nanosecond); + return std::make_shared(IntervalKind::Kind::Nanosecond); } REGISTER_FUNCTION(DateTime64Diff) diff --git a/src/Processors/QueryPlan/PartsSplitter.cpp b/src/Processors/QueryPlan/PartsSplitter.cpp index ac6bba8a2631..0fc6ddd64081 100644 --- a/src/Processors/QueryPlan/PartsSplitter.cpp +++ b/src/Processors/QueryPlan/PartsSplitter.cpp @@ -349,7 +349,7 @@ SplitPartsRangesResult splitPartsRanges(RangesInDataParts ranges_in_data_parts, if (previous_part_range.event == PartsRangesIterator::EventType::RangeStart) { /// If part level is 0, we must process whole previous part because it can contain duplicate primary keys - if (force_process_all_ranges || ranges_in_data_parts[previous_part_range.part_index].data_part->info.level == 0) + if (ranges_in_data_parts[previous_part_range.part_index].data_part->info.level == 0) continue; /// Case 1 Range Start after Range Start @@ -384,7 +384,7 @@ SplitPartsRangesResult splitPartsRanges(RangesInDataParts ranges_in_data_parts, MarkRange other_interval_range = other_interval_it->second; /// If part level is 0, we must process whole other intersecting part because it can contain duplicate primary keys - if (force_process_all_ranges || ranges_in_data_parts[other_interval_part_index].data_part->info.level == 0) + if (ranges_in_data_parts[other_interval_part_index].data_part->info.level == 0) continue; /// Case 2 Range Start after Range End @@ -419,7 +419,7 @@ SplitPartsRangesResult splitPartsRanges(RangesInDataParts ranges_in_data_parts, * * If part level is 0, we must process whole part because it can contain duplicate primary keys. */ - if (intersecting_parts != 1 || force_process_all_ranges || ranges_in_data_parts[current_part_range.part_index].data_part->info.level == 0) + if (intersecting_parts != 1 || ranges_in_data_parts[current_part_range.part_index].data_part->info.level == 0) { add_intersecting_range(current_part_range.part_index, part_index_start_to_range[current_part_range.part_index]); part_index_start_to_range.erase(current_part_range.part_index); diff --git a/src/Storages/System/StorageSystemSchema.cpp b/src/Storages/System/StorageSystemSchema.cpp index 5f356af7c194..a0dd1560c7b0 100644 --- a/src/Storages/System/StorageSystemSchema.cpp +++ b/src/Storages/System/StorageSystemSchema.cpp @@ -24,15 +24,6 @@ namespace ErrorCodes extern const int LOGICAL_ERROR; } -NamesAndTypesList StorageSystemSchema::getNamesAndTypes() -{ - return { - {"ColumnName", std::make_shared()}, - {"ColumnOrdinal", std::make_shared()}, - {"DataType", std::make_shared()}, - {"ColumnType", std::make_shared()}}; -} - void StorageSystemSchema::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const { if (res_columns.size() != 4) @@ -60,4 +51,15 @@ void StorageSystemSchema::fillData(MutableColumns & res_columns, ContextPtr cont column_types->insert(toField(is_kql ? toKQLDataTypeName(type) : type_name)); } } + +ColumnsDescription StorageSystemSchema::getColumnsDescription() +{ + return ColumnsDescription + { + {"ColumnName", std::make_shared(), "Name of the column."}, + {"ColumnOrdinal", std::make_shared(), "Ordinal of the column."}, + {"DataType", std::make_shared(), "Data type of the column."}, + {"ColumnType", std::make_shared(), "Type of the column."} + }; +} } diff --git a/src/Storages/System/StorageSystemSchema.h b/src/Storages/System/StorageSystemSchema.h index 69525d5006ff..be6264e24f59 100644 --- a/src/Storages/System/StorageSystemSchema.h +++ b/src/Storages/System/StorageSystemSchema.h @@ -7,13 +7,12 @@ namespace DB class StorageSystemSchema : public IStorageSystemOneBlock { public: - static NamesAndTypesList getNamesAndTypes(); - StorageSystemSchema(StorageID table_id_, ASTPtr query_) : IStorageSystemOneBlock(std::move(table_id_)), query(std::move(query_)) { } ~StorageSystemSchema() override = default; void fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo & query_info) const override; std::string getName() const override { return "SystemSchema"; } + static ColumnsDescription getColumnsDescription(); private: ASTPtr query; diff --git a/src/TableFunctions/TableFunctionGetSchema.cpp b/src/TableFunctions/TableFunctionGetSchema.cpp index 21767dc2882d..e12c41b10ee7 100644 --- a/src/TableFunctions/TableFunctionGetSchema.cpp +++ b/src/TableFunctions/TableFunctionGetSchema.cpp @@ -15,7 +15,7 @@ namespace ErrorCodes ColumnsDescription TableFunctionGetSchema::getActualTableStructure(ContextPtr, bool /*is_insert_query*/) const { - return ColumnsDescription{StorageSystemSchema::getNamesAndTypes()}; + return StorageSystemSchema::getColumnsDescription(); } void TableFunctionGetSchema::parseArguments(const ASTPtr &, ContextPtr)