Skip to content

Commit aac07dd

Browse files
committed
fix_partition
1 parent db33942 commit aac07dd

File tree

3 files changed

+62
-27
lines changed

3 files changed

+62
-27
lines changed

be/src/exec/tablet_info.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,32 @@ Status VOlapTablePartitionParam::init() {
538538
}
539539
}
540540

541+
// Debug: dump all partitions BE currently holds
542+
if (_is_in_partition) {
543+
LOG(WARNING) << "=== BE PARTITIONS (LIST) count=" << _partitions.size();
544+
for (auto* part : _partitions) {
545+
LOG(WARNING) << "Partition id=" << part->id << " in_keys=" << part->in_keys.size();
546+
for (size_t ik = 0; ik < part->in_keys.size(); ++ik) {
547+
auto& br = part->in_keys[ik];
548+
LOG(WARNING) << " in_key[" << ik
549+
<< "]: " << br.first->dump_data_json(br.second, 1);
550+
}
551+
}
552+
} else {
553+
LOG(WARNING) << "=== BE PARTITIONS (RANGE) count=" << _partitions.size();
554+
for (auto* part : _partitions) {
555+
std::string start =
556+
part->start_key.second == -1
557+
? std::string("(min)")
558+
: part->start_key.first->dump_data_json(part->start_key.second, 1);
559+
std::string end = part->end_key.second == -1 ? std::string("(max)")
560+
: part->end_key.first->dump_data_json(
561+
part->end_key.second, 1);
562+
LOG(WARNING) << "Partition id=" << part->id << " range: [" << start << ", " << end
563+
<< ")";
564+
}
565+
}
566+
541567
_mem_usage = _partition_block.allocated_bytes();
542568
_mem_tracker->consume(_mem_usage);
543569
return Status::OK();
@@ -584,13 +610,19 @@ static Status _create_partition_key(const TExprNode& t_expr, BlockRow* part_key,
584610
}
585611
column->insert_data(reinterpret_cast<const char*>(&dt), 0);
586612
} else {
613+
// TYPE_DATE (DATEV1) or TYPE_DATETIME (DATETIMEV1)
587614
VecDateTimeValue dt;
588615
if (!dt.from_date_str(t_expr.date_literal.value.c_str(),
589616
t_expr.date_literal.value.size())) {
590617
std::stringstream ss;
591618
ss << "invalid date literal in partition column, date=" << t_expr.date_literal;
592619
return Status::InternalError(ss.str());
593620
}
621+
if (vectorized::DataTypeFactory::instance()
622+
.create_data_type(t_expr.type)
623+
->get_primitive_type() == TYPE_DATE) {
624+
dt.cast_to_date();
625+
}
594626
column->insert_data(reinterpret_cast<const char*>(&dt), 0);
595627
}
596628
break;

regression-test/data/correctness_p0/test_function_signature_all_types.out

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,11 @@ March
442442
2 2024-02-16T00:00 feb1
443443
3 2024-03-16T00:00 mar1
444444

445+
-- !datev1_list_partitionv4 --
446+
1 2024-01-17 jan1
447+
2 2024-02-16 feb1
448+
3 2024-03-16 mar1
449+
445450
-- !datev1_bucket --
446451
1 2024-01-15 val1
447452
2 2024-02-16 val2

regression-test/suites/correctness_p0/test_function_signature_all_types.groovy

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ suite("test_function_signature_all_types", 'nonConcurrent') {
3030
sql "SET enable_nereids_planner=true"
3131
sql "SET enable_fallback_to_original_planner=false"
3232

33-
// 创建测试表,包含各种数据类型
3433
sql """
3534
DROP TABLE IF EXISTS test_sig_all_types
3635
"""
@@ -66,7 +65,6 @@ suite("test_function_signature_all_types", 'nonConcurrent') {
6665
)
6766
"""
6867

69-
// 插入测试数据
7068
sql """
7169
INSERT INTO test_sig_all_types VALUES
7270
(0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 'zero', 'zero', 'zero', '2023-12-15', '2023-12-15 00:00:00', '2023-12-15', '2023-12-15 00:00:00', false),
@@ -515,31 +513,31 @@ suite("test_function_signature_all_types", 'nonConcurrent') {
515513
sql "DROP TABLE IF EXISTS test_datev1_list_partitionv3"
516514

517515
// Test 1.1: DATEV1 as List Partition key (v4)
518-
// sql """
519-
// DROP TABLE IF EXISTS test_datev1_list_partitionv4
520-
// """
521-
// sql """
522-
// CREATE TABLE test_datev1_list_partitionv4 (
523-
// id INT,
524-
// dt DATEV1,
525-
// value VARCHAR(100)
526-
// ) DUPLICATE KEY(id)
527-
// PARTITION BY LIST(dt) (
528-
// PARTITION p1 VALUES IN ('2024-01-15', '2024-01-16', '2024-01-17'),
529-
// PARTITION p2 VALUES IN ('2024-02-15', '2024-02-16', '2024-02-17'),
530-
// PARTITION p3 VALUES IN ('2024-03-15', '2024-03-16', '2024-03-17')
531-
// )
532-
// DISTRIBUTED BY HASH(id) BUCKETS 3
533-
// PROPERTIES ("replication_num" = "1")
534-
// """
535-
// sql """
536-
// INSERT INTO test_datev1_list_partitionv4 VALUES
537-
// (1, '2024-01-17', 'jan1'),
538-
// (2, '2024-02-16', 'feb1'),
539-
// (3, '2024-03-16', 'mar1')
540-
// """
541-
// qt_datev1_list_partitionv4 "SELECT * FROM test_datev1_list_partitionv4 ORDER BY id"
542-
// sql "DROP TABLE IF EXISTS test_datev1_list_partitionv4"
516+
sql """
517+
DROP TABLE IF EXISTS test_datev1_list_partitionv4
518+
"""
519+
sql """
520+
CREATE TABLE test_datev1_list_partitionv4 (
521+
id INT,
522+
dt DATEV1,
523+
value VARCHAR(100)
524+
) DUPLICATE KEY(id)
525+
PARTITION BY LIST(dt) (
526+
PARTITION p1 VALUES IN ('2024-01-15', '2024-01-16', '2024-01-17'),
527+
PARTITION p2 VALUES IN ('2024-02-15', '2024-02-16', '2024-02-17'),
528+
PARTITION p3 VALUES IN ('2024-03-15', '2024-03-16', '2024-03-17')
529+
)
530+
DISTRIBUTED BY HASH(id) BUCKETS 3
531+
PROPERTIES ("replication_num" = "1")
532+
"""
533+
sql """
534+
INSERT INTO test_datev1_list_partitionv4 VALUES
535+
(1, '2024-01-17', 'jan1'),
536+
(2, '2024-02-16', 'feb1'),
537+
(3, '2024-03-16', 'mar1')
538+
"""
539+
qt_datev1_list_partitionv4 "SELECT * FROM test_datev1_list_partitionv4 ORDER BY id"
540+
sql "DROP TABLE IF EXISTS test_datev1_list_partitionv4"
543541

544542
// Test 2: DATEV1 as bucketing key
545543
sql """

0 commit comments

Comments
 (0)