File tree Expand file tree Collapse file tree
iceberg-handler/src/main/java/org/apache/iceberg/mr/hive
patched-iceberg-core/src/main/java/org/apache/iceberg/view Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -409,14 +409,20 @@ private void handleAlterTableOperationBasedOnType(
409409 handleChangeColumn (hmsTable );
410410 } else {
411411 setWriteModeDefaults (
412- icebergTable != null ?
413- icebergTable :
414- icebergMaterializedView .getStorageTable (),
412+ getIcebergTbl (),
415413 hmsTable .getParameters (), context );
416414 assertNotCrossTableMetadataLocationChange (hmsTable .getParameters (), context );
417415 }
418416 }
419417
418+ private Table getIcebergTbl () {
419+ if (icebergMaterializedView != null ) {
420+ return icebergMaterializedView .getStorageTable ();
421+ }
422+
423+ return icebergTable ;
424+ }
425+
420426 /**
421427 * Perform a check on the current iceberg table whether a metadata change can be performed. A table is eligible if
422428 * the current metadata uuid and the new metadata uuid matches.
Original file line number Diff line number Diff line change 2222import java .util .Arrays ;
2323import java .util .List ;
2424import java .util .Map ;
25+ import org .apache .commons .lang3 .StringUtils ;
2526import org .apache .iceberg .BaseMetastoreCatalog ;
2627import org .apache .iceberg .CatalogProperties ;
2728import org .apache .iceberg .EnvironmentContext ;
@@ -214,9 +215,16 @@ private View create(ViewOperations ops) {
214215 Preconditions .checkState (
215216 null != defaultNamespace , "Cannot create view without specifying a default namespace" );
216217
217- StorageTable storageTable = ImmutableStorageTable .of (
218- Arrays .asList (this .identifier .namespace ().levels ()), storageTableName
219- );
218+ StorageTable storageTable = null ;
219+ if (!StringUtils .isEmpty (storageTableName )) {
220+ ImmutableStorageTable .of (
221+ Arrays .asList (this .identifier .namespace ().levels ()), storageTableName
222+ );
223+ }
224+
225+ if (createTime == null ) {
226+ createTime = System .currentTimeMillis ();
227+ }
220228
221229 ViewVersion viewVersion =
222230 ImmutableViewVersion .builder ()
Original file line number Diff line number Diff line change @@ -141,8 +141,8 @@ public static ViewVersion fromJson(JsonNode node) {
141141 Namespace .of (JsonUtil .getStringArray (JsonUtil .get (DEFAULT_NAMESPACE , node )));
142142
143143 StorageTable storageTable = null ;
144- JsonNode serializedStorageTable = JsonUtil . get (STORAGE_TABLE , node );
145- if ( serializedStorageTable != null ) {
144+ if ( node . hasNonNull (STORAGE_TABLE )) {
145+ JsonNode serializedStorageTable = JsonUtil . get ( STORAGE_TABLE , node );
146146 JsonNode serializedNamespace = JsonUtil .get (NAMESPACE , serializedStorageTable );
147147 Preconditions .checkArgument (
148148 serializedNamespace .isArray (),
@@ -154,8 +154,8 @@ public static ViewVersion fromJson(JsonNode node) {
154154 }
155155
156156 RefreshState refreshState = null ;
157- JsonNode serializedRefreshState = JsonUtil . get (REFRESH_STATE , node );
158- if ( serializedRefreshState != null ) {
157+ if ( node . hasNonNull (REFRESH_STATE )) {
158+ JsonNode serializedRefreshState = JsonUtil . get ( REFRESH_STATE , node );
159159 Integer viewVersionId = JsonUtil .getInt (VIEW_VERSION_ID , serializedRefreshState );
160160
161161 JsonNode serializedSourceStates = JsonUtil .get (SOURCE_STATES , serializedRefreshState );
You can’t perform that action at this time.
0 commit comments