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 @@ -22,4 +22,49 @@ insert into test_tb_mix_format values (1,1,'b'),(2,1,'b'),(3,1,'b'),(4,1,'b'),(5
-- update some data, these splits will be readed by jni
insert into test_tb_mix_format values (1,2,'b'),(2,2,'b'),(3,2,'b'),(4,2,'b'),(5,2,'b');
-- delete foramt in table properties, doris should get format by file name
alter table test_tb_mix_format unset TBLPROPERTIES ('file.format');
alter table test_tb_mix_format unset TBLPROPERTIES ('file.format');

drop table if exists two_partition;
CREATE TABLE two_partition (
id BIGINT,
create_date STRING,
region STRING
) PARTITIONED BY (create_date,region) TBLPROPERTIES (
'primary-key' = 'create_date,region,id',
'bucket'=10,
'file.format'='orc'
);

insert into two_partition values(1,'2020-01-01','bj');
insert into two_partition values(2,'2020-01-01','sh');
insert into two_partition values(3,'2038-01-01','bj');
insert into two_partition values(4,'2038-01-01','sh');
insert into two_partition values(5,'2038-01-02','bj');

drop table if exists null_partition;
CREATE TABLE null_partition (
id BIGINT,
region STRING
) PARTITIONED BY (region) TBLPROPERTIES (
'primary-key' = 'region,id',
'bucket'=10,
'file.format'='orc'
);
-- null NULL "null" all will be in partition [null]
insert into null_partition values(1,'bj');
insert into null_partition values(2,null);
insert into null_partition values(3,NULL);
insert into null_partition values(4,'null');
insert into null_partition values(5,'NULL');

drop table if exists date_partition;
CREATE TABLE date_partition (
id BIGINT,
create_date DATE
) PARTITIONED BY (create_date) TBLPROPERTIES (
'primary-key' = 'create_date,id',
'bucket'=10,
'file.format'='orc'
);

insert into date_partition values(1,date '2020-01-01');
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,17 @@ public long fetchRowCount() {

@Override
public List<Column> getPartitionColumns(Optional<MvccSnapshot> snapshot) {
if (isPartitionInvalid(snapshot)) {
return Collections.emptyList();
}
return getPaimonSchemaCacheValue(snapshot).getPartitionColumns();
}

private boolean isPartitionInvalid(Optional<MvccSnapshot> snapshot) {
PaimonSnapshotCacheValue paimonSnapshotCacheValue = getOrFetchSnapshotCacheValue(snapshot);
return paimonSnapshotCacheValue.getPartitionInfo().isPartitionInvalid();
}

@Override
public MvccSnapshot loadSnapshot() {
return new PaimonMvccSnapshot(getPaimonSnapshotCacheValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ public Map<String, PartitionItem> getNameToPartitionItem() {
public Map<String, PaimonPartition> getNameToPartition() {
return nameToPartition;
}

public boolean isPartitionInvalid() {
// when transfer to partitionItem failed, will not equal
return nameToPartitionItem.size() != nameToPartition.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static PaimonPartition rowToPartition(InternalRow row) {
}

public static PaimonPartitionInfo generatePartitionInfo(List<Column> partitionColumns,
List<PaimonPartition> paimonPartitions) throws AnalysisException {
List<PaimonPartition> paimonPartitions) {
Map<String, PartitionItem> nameToPartitionItem = Maps.newHashMap();
Map<String, PaimonPartition> nameToPartition = Maps.newHashMap();
PaimonPartitionInfo partitionInfo = new PaimonPartitionInfo(nameToPartitionItem, nameToPartition);
Expand All @@ -127,7 +127,14 @@ public static PaimonPartitionInfo generatePartitionInfo(List<Column> partitionCo
for (PaimonPartition paimonPartition : paimonPartitions) {
String partitionName = getPartitionName(partitionColumns, paimonPartition.getPartitionValues());
nameToPartition.put(partitionName, paimonPartition);
nameToPartitionItem.put(partitionName, toListPartitionItem(partitionName, partitionColumns));
try {
// partition values return by paimon api, may have problem,
// to avoid affecting the query, we catch exceptions here
nameToPartitionItem.put(partitionName, toListPartitionItem(partitionName, partitionColumns));
} catch (Exception e) {
LOG.warn("toListPartitionItem failed, partitionColumns: {}, partitionValues: {}", partitionColumns,
paimonPartition.getPartitionValues(), e);
}
}
return partitionInfo;
}
Expand Down
Loading