135
135
import static com .facebook .presto .iceberg .IcebergPartitionType .ALL ;
136
136
import static com .facebook .presto .iceberg .IcebergSessionProperties .getCompressionCodec ;
137
137
import static com .facebook .presto .iceberg .IcebergSessionProperties .isPushdownFilterEnabled ;
138
- import static com .facebook .presto .iceberg .IcebergTableProperties .COMMIT_RETRIES ;
139
- import static com .facebook .presto .iceberg .IcebergTableProperties .DELETE_MODE ;
140
- import static com .facebook .presto .iceberg .IcebergTableProperties .FILE_FORMAT_PROPERTY ;
141
- import static com .facebook .presto .iceberg .IcebergTableProperties .FORMAT_VERSION ;
142
138
import static com .facebook .presto .iceberg .IcebergTableProperties .LOCATION_PROPERTY ;
143
- import static com .facebook .presto .iceberg .IcebergTableProperties .METADATA_DELETE_AFTER_COMMIT ;
144
- import static com .facebook .presto .iceberg .IcebergTableProperties .METADATA_PREVIOUS_VERSIONS_MAX ;
145
- import static com .facebook .presto .iceberg .IcebergTableProperties .METRICS_MAX_INFERRED_COLUMN ;
146
139
import static com .facebook .presto .iceberg .IcebergTableProperties .PARTITIONING_PROPERTY ;
147
140
import static com .facebook .presto .iceberg .IcebergTableProperties .SORTED_BY_PROPERTY ;
148
141
import static com .facebook .presto .iceberg .IcebergTableType .CHANGELOG ;
166
159
import static com .facebook .presto .iceberg .IcebergUtil .tryGetProperties ;
167
160
import static com .facebook .presto .iceberg .IcebergUtil .tryGetSchema ;
168
161
import static com .facebook .presto .iceberg .IcebergUtil .validateTableMode ;
162
+ import static com .facebook .presto .iceberg .IcebergWarningCode .SORT_COLUMN_TRANSFORM_NOT_SUPPORTED_WARNING ;
163
+ import static com .facebook .presto .iceberg .IcebergWarningCode .USE_OF_DEPRECATED_TABLE_PROPERTY ;
169
164
import static com .facebook .presto .iceberg .PartitionFields .getPartitionColumnName ;
170
165
import static com .facebook .presto .iceberg .PartitionFields .getTransformTerm ;
171
166
import static com .facebook .presto .iceberg .PartitionFields .toPartitionFields ;
185
180
import static com .facebook .presto .iceberg .util .StatisticsUtil .calculateBaseTableStatistics ;
186
181
import static com .facebook .presto .iceberg .util .StatisticsUtil .calculateStatisticsConsideringLayout ;
187
182
import static com .facebook .presto .spi .StandardErrorCode .NOT_SUPPORTED ;
188
- import static com .facebook .presto .spi .StandardWarningCode .SORT_COLUMN_TRANSFORM_NOT_SUPPORTED_WARNING ;
189
183
import static com .facebook .presto .spi .statistics .TableStatisticType .ROW_COUNT ;
190
184
import static com .google .common .base .Verify .verify ;
191
185
import static com .google .common .collect .ImmutableList .toImmutableList ;
201
195
import static org .apache .iceberg .SnapshotSummary .REMOVED_POS_DELETES_PROP ;
202
196
import static org .apache .iceberg .TableProperties .DELETE_ISOLATION_LEVEL ;
203
197
import static org .apache .iceberg .TableProperties .DELETE_ISOLATION_LEVEL_DEFAULT ;
204
- import static org .apache .iceberg .TableProperties .SPLIT_SIZE ;
205
- import static org .apache .iceberg .TableProperties .UPDATE_MODE ;
206
198
207
199
public abstract class IcebergAbstractMetadata
208
200
implements ConnectorMetadata
@@ -217,6 +209,7 @@ public abstract class IcebergAbstractMetadata
217
209
protected final FilterStatsCalculatorService filterStatsCalculatorService ;
218
210
protected Transaction transaction ;
219
211
protected final StatisticsFileCache statisticsFileCache ;
212
+ protected final IcebergTableProperties tableProperties ;
220
213
221
214
private final StandardFunctionResolution functionResolution ;
222
215
private final ConcurrentMap <SchemaTableName , Table > icebergTables = new ConcurrentHashMap <>();
@@ -228,7 +221,8 @@ public IcebergAbstractMetadata(
228
221
JsonCodec <CommitTaskData > commitTaskCodec ,
229
222
NodeVersion nodeVersion ,
230
223
FilterStatsCalculatorService filterStatsCalculatorService ,
231
- StatisticsFileCache statisticsFileCache )
224
+ StatisticsFileCache statisticsFileCache ,
225
+ IcebergTableProperties tableProperties )
232
226
{
233
227
this .typeManager = requireNonNull (typeManager , "typeManager is null" );
234
228
this .commitTaskCodec = requireNonNull (commitTaskCodec , "commitTaskCodec is null" );
@@ -237,6 +231,7 @@ public IcebergAbstractMetadata(
237
231
this .nodeVersion = requireNonNull (nodeVersion , "nodeVersion is null" );
238
232
this .filterStatsCalculatorService = requireNonNull (filterStatsCalculatorService , "filterStatsCalculatorService is null" );
239
233
this .statisticsFileCache = requireNonNull (statisticsFileCache , "statisticsFileCache is null" );
234
+ this .tableProperties = requireNonNull (tableProperties , "tableProperties is null" );
240
235
}
241
236
242
237
protected final Table getIcebergTable (ConnectorSession session , SchemaTableName schemaTableName )
@@ -702,10 +697,10 @@ private static String columnExtraInfo(List<String> partitionTransforms)
702
697
protected ImmutableMap <String , Object > createMetadataProperties (Table icebergTable , ConnectorSession session )
703
698
{
704
699
ImmutableMap .Builder <String , Object > properties = ImmutableMap .builder ();
705
- properties .put (FILE_FORMAT_PROPERTY , getFileFormat (icebergTable ));
700
+ properties .put (TableProperties . DEFAULT_FILE_FORMAT , getFileFormat (icebergTable ));
706
701
707
702
int formatVersion = ((BaseTable ) icebergTable ).operations ().current ().formatVersion ();
708
- properties .put (FORMAT_VERSION , String .valueOf (formatVersion ));
703
+ properties .put (TableProperties . FORMAT_VERSION , String .valueOf (formatVersion ));
709
704
710
705
if (!icebergTable .spec ().fields ().isEmpty ()) {
711
706
properties .put (PARTITIONING_PROPERTY , toPartitionFields (icebergTable .spec ()));
@@ -715,12 +710,12 @@ protected ImmutableMap<String, Object> createMetadataProperties(Table icebergTab
715
710
properties .put (LOCATION_PROPERTY , icebergTable .location ());
716
711
}
717
712
718
- properties .put (DELETE_MODE , IcebergUtil .getDeleteMode (icebergTable ));
719
- properties .put (UPDATE_MODE , IcebergUtil .getUpdateMode (icebergTable ));
720
- properties .put (METADATA_PREVIOUS_VERSIONS_MAX , IcebergUtil .getMetadataPreviousVersionsMax (icebergTable ));
721
- properties .put (METADATA_DELETE_AFTER_COMMIT , IcebergUtil .isMetadataDeleteAfterCommit (icebergTable ));
722
- properties .put (METRICS_MAX_INFERRED_COLUMN , IcebergUtil .getMetricsMaxInferredColumn (icebergTable ));
723
- properties .put (SPLIT_SIZE , IcebergUtil .getSplitSize (icebergTable ));
713
+ properties .put (TableProperties . DELETE_MODE , IcebergUtil .getDeleteMode (icebergTable ));
714
+ properties .put (TableProperties . UPDATE_MODE , IcebergUtil .getUpdateMode (icebergTable ));
715
+ properties .put (TableProperties . METADATA_PREVIOUS_VERSIONS_MAX , IcebergUtil .getMetadataPreviousVersionsMax (icebergTable ));
716
+ properties .put (TableProperties . METADATA_DELETE_AFTER_COMMIT_ENABLED , IcebergUtil .isMetadataDeleteAfterCommit (icebergTable ));
717
+ properties .put (TableProperties . METRICS_MAX_INFERRED_COLUMN_DEFAULTS , IcebergUtil .getMetricsMaxInferredColumn (icebergTable ));
718
+ properties .put (TableProperties . SPLIT_SIZE , IcebergUtil .getSplitSize (icebergTable ));
724
719
725
720
SortOrder sortOrder = icebergTable .sortOrder ();
726
721
// TODO: Support sort column transforms (https://github.com/prestodb/presto/issues/24250)
@@ -1125,22 +1120,36 @@ public void setTableProperties(ConnectorSession session, ConnectorTableHandle ta
1125
1120
1126
1121
UpdateProperties updateProperties = transaction .updateProperties ();
1127
1122
for (Map .Entry <String , Object > entry : properties .entrySet ()) {
1128
- switch (entry .getKey ()) {
1129
- case COMMIT_RETRIES :
1130
- updateProperties .set (TableProperties .COMMIT_NUM_RETRIES , String .valueOf (entry .getValue ()));
1131
- break ;
1132
- case SPLIT_SIZE :
1133
- updateProperties .set (TableProperties .SPLIT_SIZE , entry .getValue ().toString ());
1134
- break ;
1135
- default :
1136
- throw new PrestoException (NOT_SUPPORTED , "Updating property " + entry .getKey () + " is not supported currently" );
1123
+ if (!tableProperties .getUpdatableProperties ()
1124
+ .contains (entry .getKey ())) {
1125
+ throw new PrestoException (NOT_SUPPORTED , "Updating property " + entry .getKey () + " is not supported currently" );
1137
1126
}
1127
+ String propertyName = entry .getKey ();
1128
+ if (tableProperties .getDeprecatedProperties ().containsKey (entry .getKey ())) {
1129
+ String newPropertyKey = tableProperties .getDeprecatedProperties ().get (entry .getKey ());
1130
+ PrestoWarning warning = getPrestoWarning (newPropertyKey , propertyName );
1131
+ session .getWarningCollector ().add (warning );
1132
+ propertyName = newPropertyKey ;
1133
+ }
1134
+ updateProperties .set (propertyName , String .valueOf (entry .getValue ()));
1138
1135
}
1139
1136
1140
1137
updateProperties .commit ();
1141
1138
transaction .commitTransaction ();
1142
1139
}
1143
1140
1141
+ private static PrestoWarning getPrestoWarning (String newPropertyKey , String propertyName )
1142
+ {
1143
+ PrestoWarning warning ;
1144
+ if (newPropertyKey == null ) {
1145
+ warning = new PrestoWarning (USE_OF_DEPRECATED_TABLE_PROPERTY , format ("Property \" %s\" is deprecated and will be completely removed in a future version. Avoid using immediately." , propertyName ));
1146
+ }
1147
+ else {
1148
+ warning = new PrestoWarning (USE_OF_DEPRECATED_TABLE_PROPERTY , format ("Property \" %s\" has been renamed to \" %s\" . This will become an error in future versions." , propertyName , newPropertyKey ));
1149
+ }
1150
+ return warning ;
1151
+ }
1152
+
1144
1153
/**
1145
1154
* Deletes all the files for a specific predicate
1146
1155
*
0 commit comments