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
+ import org .apache .iceberg .FileScanTask ;
41
41
import org .apache .iceberg .MetadataTableType ;
42
42
import org .apache .iceberg .MetadataTableUtils ;
43
43
import org .apache .iceberg .Table ;
44
+ import org .apache .iceberg .io .CloseableIterable ;
44
45
import org .apache .iceberg .util .SerializationUtil ;
45
46
46
- import java .util .Collections ;
47
47
import java .util .List ;
48
48
import java .util .Map ;
49
- import java .util .stream .Collectors ;
50
49
51
50
/**
52
51
* The class of table valued function for iceberg metadata.
@@ -59,9 +58,6 @@ public class IcebergTableValuedFunction extends MetadataTableValuedFunction {
59
58
public static final String QUERY_TYPE = "query_type" ;
60
59
61
60
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
61
66
62
private final TIcebergQueryType queryType ;
67
63
private final Map <String , String > hadoopProps ;
@@ -114,6 +110,7 @@ public IcebergTableValuedFunction(TableName icebergTableName, TIcebergQueryType
114
110
}
115
111
ExternalCatalog externalCatalog = (ExternalCatalog ) catalog ;
116
112
hadoopProps = externalCatalog .getCatalogProperty ().getHadoopProperties ();
113
+ // catalog.getPreExecutionAuthenticator().execute
117
114
Table table = IcebergUtils .getIcebergTable (externalCatalog , icebergTableName .getDb (),
118
115
icebergTableName .getTbl ());
119
116
if (table == null ) {
@@ -138,17 +135,17 @@ public TMetadataType getMetadataType() {
138
135
@ Override
139
136
public List <TMetaScanRange > getMetaScanRanges () {
140
137
List <TMetaScanRange > scanRanges = Lists .newArrayList ();
141
- List <String > splits = getSplits ();
142
138
String serializedTable = SerializationUtil .serializeToBase64 (table );
143
- for (String split : splits ) {
139
+ CloseableIterable <FileScanTask > splits = sysTable .newScan ().planFiles ();
140
+ for (FileScanTask split : splits ) {
144
141
TMetaScanRange metaScanRange = new TMetaScanRange ();
145
142
metaScanRange .setMetadataType (TMetadataType .ICEBERG );
146
143
// set iceberg metadata params
147
144
TIcebergMetadataParams icebergMetadataParams = new TIcebergMetadataParams ();
148
145
icebergMetadataParams .setIcebergQueryType (queryType );
149
146
icebergMetadataParams .setSerializedTable (serializedTable );
150
147
icebergMetadataParams .setHadoopProps (hadoopProps );
151
- icebergMetadataParams .setSerializedSplit (split );
148
+ icebergMetadataParams .setSerializedSplit (SerializationUtil . serializeToBase64 ( split ) );
152
149
metaScanRange .setIcebergParams (icebergMetadataParams );
153
150
scanRanges .add (metaScanRange );
154
151
}
@@ -165,31 +162,4 @@ public String getTableName() {
165
162
public List <Column > getTableColumns () {
166
163
return schema ;
167
164
}
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
165
}
0 commit comments