Skip to content

Commit 5da3ff5

Browse files
authored
[spark] Fix reported statistics does not do column pruning (#4137)
1 parent dd386ba commit 5da3ff5

File tree

24 files changed

+208
-9
lines changed

24 files changed

+208
-9
lines changed

paimon-common/src/main/java/org/apache/paimon/types/ArrayType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public DataType getElementType() {
5757
return elementType;
5858
}
5959

60+
@Override
61+
public int defaultSize() {
62+
return elementType.defaultSize();
63+
}
64+
6065
@Override
6166
public DataType copy(boolean isNullable) {
6267
return new ArrayType(isNullable, elementType.copy());

paimon-common/src/main/java/org/apache/paimon/types/BigIntType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public BigIntType() {
4141
this(true);
4242
}
4343

44+
@Override
45+
public int defaultSize() {
46+
return 8;
47+
}
48+
4449
@Override
4550
public DataType copy(boolean isNullable) {
4651
return new BigIntType(isNullable);

paimon-common/src/main/java/org/apache/paimon/types/BinaryType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public int getLength() {
6565
return length;
6666
}
6767

68+
@Override
69+
public int defaultSize() {
70+
return length;
71+
}
72+
6873
@Override
6974
public DataType copy(boolean isNullable) {
7075
return new BinaryType(isNullable, length);

paimon-common/src/main/java/org/apache/paimon/types/BooleanType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public BooleanType() {
4040
this(true);
4141
}
4242

43+
@Override
44+
public int defaultSize() {
45+
return 1;
46+
}
47+
4348
@Override
4449
public DataType copy(boolean isNullable) {
4550
return new BooleanType(isNullable);

paimon-common/src/main/java/org/apache/paimon/types/CharType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public int getLength() {
6767
return length;
6868
}
6969

70+
@Override
71+
public int defaultSize() {
72+
return length;
73+
}
74+
7075
@Override
7176
public DataType copy(boolean isNullable) {
7277
return new CharType(isNullable, length);

paimon-common/src/main/java/org/apache/paimon/types/DataType.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public boolean is(DataTypeFamily family) {
104104
return typeRoot.getFamilies().contains(family);
105105
}
106106

107+
/** The default size of a value of this data type, used internally for size estimation. */
108+
public abstract int defaultSize();
109+
107110
/**
108111
* Returns a deep copy of this type with possibly different nullability.
109112
*

paimon-common/src/main/java/org/apache/paimon/types/DateType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public DateType() {
4444
this(true);
4545
}
4646

47+
@Override
48+
public int defaultSize() {
49+
return 4;
50+
}
51+
4752
@Override
4853
public DataType copy(boolean isNullable) {
4954
return new DateType(isNullable);

paimon-common/src/main/java/org/apache/paimon/types/DecimalType.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.paimon.types;
2020

2121
import org.apache.paimon.annotation.Public;
22+
import org.apache.paimon.data.Decimal;
2223

2324
import java.util.Objects;
2425

@@ -86,6 +87,11 @@ public int getScale() {
8687
return scale;
8788
}
8889

90+
@Override
91+
public int defaultSize() {
92+
return Decimal.isCompact(precision) ? 8 : 16;
93+
}
94+
8995
@Override
9096
public DataType copy(boolean isNullable) {
9197
return new DecimalType(isNullable, precision, scale);

paimon-common/src/main/java/org/apache/paimon/types/DoubleType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public DoubleType() {
4040
this(true);
4141
}
4242

43+
@Override
44+
public int defaultSize() {
45+
return 8;
46+
}
47+
4348
@Override
4449
public DataType copy(boolean isNullable) {
4550
return new DoubleType(isNullable);

paimon-common/src/main/java/org/apache/paimon/types/FloatType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public FloatType() {
4141
this(true);
4242
}
4343

44+
@Override
45+
public int defaultSize() {
46+
return 4;
47+
}
48+
4449
@Override
4550
public DataType copy(boolean isNullable) {
4651
return new FloatType(isNullable);

0 commit comments

Comments
 (0)