Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,10 @@ public Set<String> getDistributionColumnNames() {
return distributionColumnNames;
}

public boolean isRandomDistribution() {
return defaultDistributionInfo instanceof RandomDistributionInfo;
}

public void renamePartition(String partitionName, String newPartitionName) {
if (partitionInfo.getType() == PartitionType.UNPARTITIONED) {
// bug fix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,21 @@ public FunctionalDependencies computeFuncDeps() {
@Override
public void computeUnique(FunctionalDependencies.Builder fdBuilder) {
Set<Slot> outputSet = Utils.fastToImmutableSet(getOutputSet());
if (table instanceof OlapTable && ((OlapTable) table).getKeysType().isAggregationFamily()) {
ImmutableSet.Builder<Slot> uniqSlots = ImmutableSet.builderWithExpectedSize(outputSet.size());
for (Slot slot : outputSet) {
if (!(slot instanceof SlotReference)) {
continue;
}
SlotReference slotRef = (SlotReference) slot;
if (slotRef.getColumn().isPresent() && slotRef.getColumn().get().isKey()) {
uniqSlots.add(slot);
if (table instanceof OlapTable) {
OlapTable olapTable = (OlapTable) table;
if (olapTable.getKeysType().isAggregationFamily() && !olapTable.isRandomDistribution()) {
ImmutableSet.Builder<Slot> uniqSlots = ImmutableSet.builderWithExpectedSize(outputSet.size());
for (Slot slot : outputSet) {
if (!(slot instanceof SlotReference)) {
continue;
}
SlotReference slotRef = (SlotReference) slot;
if (slotRef.getColumn().isPresent() && slotRef.getColumn().get().isKey()) {
uniqSlots.add(slot);
}
}
fdBuilder.addUniqueSlot(uniqSlots.build());
}
fdBuilder.addUniqueSlot(uniqSlots.build());
}

for (PrimaryKeyConstraint c : table.getPrimaryKeyConstraints()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,15 @@
-- !sql_16 --
2

-- !sql_17 --
1

-- !sql_18 --
1

-- !sql_19 --
1

-- !sql_20 --
1

Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,31 @@ suite("select_random_distributed_tbl") {
}

sql "drop table ${tableName};"
}

// test all keys are NOT NULL for AGG table
sql "drop table if exists random_distributed_tbl_test_2;"
sql """ CREATE TABLE random_distributed_tbl_test_2 (
`k1` LARGEINT NOT NULL
) ENGINE=OLAP
AGGREGATE KEY(`k1`)
COMMENT 'OLAP'
DISTRIBUTED BY RANDOM BUCKETS 10
PROPERTIES (
"replication_num" = "1"
);
"""

sql """ insert into random_distributed_tbl_test_2 values(1); """
sql """ insert into random_distributed_tbl_test_2 values(1); """
sql """ insert into random_distributed_tbl_test_2 values(1); """

sql "set enable_nereids_planner = false;"
qt_sql_17 "select k1 from random_distributed_tbl_test_2;"
qt_sql_18 "select distinct k1 from random_distributed_tbl_test_2;"

sql "set enable_nereids_planner = true;"
qt_sql_19 "select k1 from random_distributed_tbl_test_2;"
qt_sql_20 "select distinct k1 from random_distributed_tbl_test_2;"

sql "drop table random_distributed_tbl_test_2;"
}