Skip to content

Commit

Permalink
Kusto-phase3: rebase v24.2.1.2248-stable fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kothiga committed Mar 7, 2024
1 parent 0d8db6c commit 95c5ff3
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/Common/IntervalKind.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Functions/FunctionsConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/Kusto/KqlRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ class FunctionKqlRange : public IFunction
total_values = total_elements;
}

auto out = ColumnArray::create(std::make_shared<DataTypeInterval>(IntervalKind::Nanosecond)->createColumn());
auto out = ColumnArray::create(std::make_shared<DataTypeInterval>(IntervalKind::Kind::Nanosecond)->createColumn());
IColumn & out_data = out->getData();
IColumn::Offsets & out_offsets = out->getOffsets();

Expand Down
4 changes: 2 additions & 2 deletions src/Functions/Kusto/kqlDateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ ColumnPtr FunctionKqlDateTime<input_policy>::executeImpl(

const ColumnsWithTypeAndName addition_args{
asArgument(converted, "converted"),
createConstColumnWithTypeAndName<DataTypeInterval>(50, "interval_50", IntervalKind::Nanosecond)};
createConstColumnWithTypeAndName<DataTypeInterval>(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<DataTypeInterval>(100, "interval_100", IntervalKind::Nanosecond)};
asArgument(sum, "sum"), createConstColumnWithTypeAndName<DataTypeInterval>(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);
Expand Down
10 changes: 1 addition & 9 deletions src/Functions/Kusto/kqlIndexOfRegex.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
#include <Columns/ColumnNullable.h>
#include <Columns/ColumnString.h>
#include <Columns/ColumnsNumber.h>
#include <Common/re2.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/IFunction.h>

#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
#include <re2/re2.h>
#ifdef __clang__
# pragma clang diagnostic pop
#endif

namespace DB::ErrorCodes
{
extern const int CANNOT_COMPILE_REGEXP;
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/Kusto/kqlToTimespan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ColumnPtr FunctionKqlToTimespan::executeImpl(

DataTypePtr FunctionKqlToTimespan::getReturnTypeImpl(const DataTypes &) const
{
return makeNullable(std::make_shared<DataTypeInterval>(IntervalKind::Nanosecond));
return makeNullable(std::make_shared<DataTypeInterval>(IntervalKind::Kind::Nanosecond));
}

REGISTER_FUNCTION(KqlToTimespan)
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/dateTime64Diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ DataTypePtr FunctionDateTime64Diff::getReturnTypeImpl(const DataTypes & argument
rhs->getName(),
getName());

return std::make_shared<DataTypeInterval>(IntervalKind::Nanosecond);
return std::make_shared<DataTypeInterval>(IntervalKind::Kind::Nanosecond);
}

REGISTER_FUNCTION(DateTime64Diff)
Expand Down
6 changes: 3 additions & 3 deletions src/Processors/QueryPlan/PartsSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 11 additions & 9 deletions src/Storages/System/StorageSystemSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ namespace ErrorCodes
extern const int LOGICAL_ERROR;
}

NamesAndTypesList StorageSystemSchema::getNamesAndTypes()
{
return {
{"ColumnName", std::make_shared<DataTypeString>()},
{"ColumnOrdinal", std::make_shared<DataTypeInt32>()},
{"DataType", std::make_shared<DataTypeString>()},
{"ColumnType", std::make_shared<DataTypeString>()}};
}

void StorageSystemSchema::fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo &) const
{
if (res_columns.size() != 4)
Expand Down Expand Up @@ -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<DataTypeString>(), "Name of the column."},
{"ColumnOrdinal", std::make_shared<DataTypeInt32>(), "Ordinal of the column."},
{"DataType", std::make_shared<DataTypeString>(), "Data type of the column."},
{"ColumnType", std::make_shared<DataTypeString>(), "Type of the column."}
};
}
}
3 changes: 1 addition & 2 deletions src/Storages/System/StorageSystemSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ namespace DB
class StorageSystemSchema : public IStorageSystemOneBlock<StorageSystemSchema>
{
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;
Expand Down
2 changes: 1 addition & 1 deletion src/TableFunctions/TableFunctionGetSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 95c5ff3

Please sign in to comment.