MCPcopy Create free account
hub / github.com/ByConity/ByConity / checkPartitionKeyAndInitMinMax

Method checkPartitionKeyAndInitMinMax

src/MergeTreeCommon/MergeTreeMetaBase.cpp:444–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444void MergeTreeMetaBase::checkPartitionKeyAndInitMinMax(const KeyDescription & new_partition_key)
445{
446 if (new_partition_key.expression_list_ast->children.empty())
447 return;
448
449 checkKeyExpression(*new_partition_key.expression, new_partition_key.sample_block, "Partition", allow_nullable_key);
450
451 /// Add all columns used in the partition key to the min-max index.
452 DataTypes minmax_idx_columns_types = getMinMaxColumnsTypes(new_partition_key);
453
454 /// Try to find the date column in columns used by the partition key (a common case).
455 /// If there are no - DateTime or DateTime64 would also suffice.
456
457 bool has_date_column = false;
458 bool has_datetime_column = false;
459
460 for (size_t i = 0; i < minmax_idx_columns_types.size(); ++i)
461 {
462 if (isDate(minmax_idx_columns_types[i]))
463 {
464 if (!has_date_column)
465 {
466 minmax_idx_date_column_pos = i;
467 has_date_column = true;
468 }
469 else
470 {
471 /// There is more than one Date column in partition key and we don't know which one to choose.
472 minmax_idx_date_column_pos = -1;
473 }
474 }
475 }
476 if (!has_date_column)
477 {
478 for (size_t i = 0; i < minmax_idx_columns_types.size(); ++i)
479 {
480 if (isDateTime(minmax_idx_columns_types[i])
481 || isDateTime64(minmax_idx_columns_types[i])
482 )
483 {
484 if (!has_datetime_column)
485 {
486 minmax_idx_time_column_pos = i;
487 has_datetime_column = true;
488 }
489 else
490 {
491 /// There is more than one DateTime column in partition key and we don't know which one to choose.
492 minmax_idx_time_column_pos = -1;
493 }
494 }
495 }
496 }
497}
498
499
500void MergeTreeMetaBase::checkTTLExpressions(const StorageInMemoryMetadata & new_metadata, const StorageInMemoryMetadata & old_metadata) const

Callers

nothing calls this directly

Calls 6

checkKeyExpressionFunction · 0.85
isDateFunction · 0.85
isDateTimeFunction · 0.85
isDateTime64Function · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected