26
26
import org .apache .doris .datasource .CatalogIf ;
27
27
import org .apache .doris .datasource .ExternalCatalog ;
28
28
import org .apache .doris .datasource .iceberg .IcebergUtils ;
29
- import org .apache .doris .datasource .iceberg .share .ManifestFileBean ;
30
29
import org .apache .doris .mysql .privilege .PrivPredicate ;
31
30
import org .apache .doris .qe .ConnectContext ;
32
31
import org .apache .doris .thrift .TIcebergMetadataParams ;
38
37
import com .google .common .collect .ImmutableSet ;
39
38
import com .google .common .collect .Lists ;
40
39
import com .google .common .collect .Maps ;
40
+
41
+ import org .apache .iceberg .FileScanTask ;
41
42
import org .apache .iceberg .MetadataTableType ;
42
43
import org .apache .iceberg .MetadataTableUtils ;
43
44
import org .apache .iceberg .Table ;
45
+ import org .apache .iceberg .io .CloseableIterable ;
44
46
import org .apache .iceberg .util .SerializationUtil ;
45
47
46
- import java .util .Collections ;
47
48
import java .util .List ;
48
49
import java .util .Map ;
49
- import java .util .stream .Collectors ;
50
50
51
51
/**
52
52
* The class of table valued function for iceberg metadata.
@@ -59,9 +59,6 @@ public class IcebergTableValuedFunction extends MetadataTableValuedFunction {
59
59
public static final String QUERY_TYPE = "query_type" ;
60
60
61
61
private static final ImmutableSet <String > PROPERTIES_SET = ImmutableSet .of (TABLE , QUERY_TYPE );
62
- private static final ImmutableSet <TIcebergQueryType > CAN_SPLIT_TABLE_TYPES = ImmutableSet .of (
63
- TIcebergQueryType .FILES , TIcebergQueryType .DATA_FILES , TIcebergQueryType .DELETE_FILES ,
64
- TIcebergQueryType .PARTITIONS , TIcebergQueryType .POSITION_DELETES );
65
62
66
63
private final TIcebergQueryType queryType ;
67
64
private final Map <String , String > hadoopProps ;
@@ -114,6 +111,7 @@ public IcebergTableValuedFunction(TableName icebergTableName, TIcebergQueryType
114
111
}
115
112
ExternalCatalog externalCatalog = (ExternalCatalog ) catalog ;
116
113
hadoopProps = externalCatalog .getCatalogProperty ().getHadoopProperties ();
114
+ // catalog.getPreExecutionAuthenticator().execute
117
115
Table table = IcebergUtils .getIcebergTable (externalCatalog , icebergTableName .getDb (),
118
116
icebergTableName .getTbl ());
119
117
if (table == null ) {
@@ -138,17 +136,17 @@ public TMetadataType getMetadataType() {
138
136
@ Override
139
137
public List <TMetaScanRange > getMetaScanRanges () {
140
138
List <TMetaScanRange > scanRanges = Lists .newArrayList ();
141
- List <String > splits = getSplits ();
142
139
String serializedTable = SerializationUtil .serializeToBase64 (table );
143
- for (String split : splits ) {
140
+ CloseableIterable <FileScanTask > splits = sysTable .newScan ().planFiles ();
141
+ for (FileScanTask split : splits ) {
144
142
TMetaScanRange metaScanRange = new TMetaScanRange ();
145
143
metaScanRange .setMetadataType (TMetadataType .ICEBERG );
146
144
// set iceberg metadata params
147
145
TIcebergMetadataParams icebergMetadataParams = new TIcebergMetadataParams ();
148
146
icebergMetadataParams .setIcebergQueryType (queryType );
149
147
icebergMetadataParams .setSerializedTable (serializedTable );
150
148
icebergMetadataParams .setHadoopProps (hadoopProps );
151
- icebergMetadataParams .setSerializedSplit (split );
149
+ icebergMetadataParams .setSerializedSplit (SerializationUtil . serializeToBase64 ( split ) );
152
150
metaScanRange .setIcebergParams (icebergMetadataParams );
153
151
scanRanges .add (metaScanRange );
154
152
}
@@ -165,31 +163,4 @@ public String getTableName() {
165
163
public List <Column > getTableColumns () {
166
164
return schema ;
167
165
}
168
-
169
- private List <String > getSplits () {
170
- if (!CAN_SPLIT_TABLE_TYPES .contains (queryType )) {
171
- return Lists .newArrayList ("" );
172
- }
173
- if (table .currentSnapshot () == null ) {
174
- return Collections .emptyList ();
175
- }
176
- switch (queryType ) {
177
- case FILES :
178
- case PARTITIONS :
179
- return table .currentSnapshot ().allManifests (table .io ()).stream ()
180
- .map (ManifestFileBean ::fromManifest ).map (SerializationUtil ::serializeToBase64 )
181
- .collect (Collectors .toList ());
182
- case DATA_FILES :
183
- return table .currentSnapshot ().dataManifests (table .io ()).stream ()
184
- .map (ManifestFileBean ::fromManifest ).map (SerializationUtil ::serializeToBase64 )
185
- .collect (Collectors .toList ());
186
- case DELETE_FILES :
187
- case POSITION_DELETES :
188
- return table .currentSnapshot ().deleteManifests (table .io ()).stream ()
189
- .map (ManifestFileBean ::fromManifest ).map (SerializationUtil ::serializeToBase64 )
190
- .collect (Collectors .toList ());
191
- default :
192
- throw new IllegalStateException ("Unreachable state with query type " + queryType );
193
- }
194
- }
195
166
}
0 commit comments