Skip to content

Commit

Permalink
Change IcebergInstructions refreshing indicator to enum instead of bo…
Browse files Browse the repository at this point in the history
…olean
  • Loading branch information
lbooker42 committed Jul 2, 2024
1 parent a8d957a commit 264fdb1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,23 @@ private Table readTableInternal(
userInstructions);
}

if (instructions.isRefreshing()) {
if (instructions.refreshing() == IcebergInstructions.IcebergRefreshing.STATIC) {
description = "Read static iceberg table with " + keyFinder;
updateSourceRegistrar = null;

final AbstractTableLocationProvider locationProvider = new PollingTableLocationProvider<>(
StandaloneTableKey.getInstance(),
keyFinder,
new IcebergTableLocationFactory(),
null);

return new PartitionAwareSourceTable(
tableDef,
description,
RegionedTableComponentFactoryImpl.INSTANCE,
locationProvider,
updateSourceRegistrar);
} else if (instructions.refreshing() == IcebergInstructions.IcebergRefreshing.MANUAL_REFRESHING) {
description = "Read refreshing iceberg table with " + keyFinder;
updateSourceRegistrar = ExecutionContext.getContext().getUpdateGraph();

Expand All @@ -528,22 +544,9 @@ private Table readTableInternal(
locationProvider,
updateSourceRegistrar);
} else {
description = "Read static iceberg table with " + keyFinder;
updateSourceRegistrar = null;

final AbstractTableLocationProvider locationProvider = new PollingTableLocationProvider<>(
StandaloneTableKey.getInstance(),
keyFinder,
new IcebergTableLocationFactory(),
null);

return new PartitionAwareSourceTable(
tableDef,
description,
RegionedTableComponentFactoryImpl.INSTANCE,
locationProvider,
updateSourceRegistrar);
throw new UnsupportedOperationException("Unsupported refreshing mode: " + instructions.refreshing());
}

}

private static KnownLocationKeyFinder<IcebergTableLocationKey> toKnownKeys(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public abstract class IcebergInstructions {
@SuppressWarnings("unused")
public static final IcebergInstructions DEFAULT = builder().build();

public enum IcebergRefreshing {
STATIC,
AUTO_REFRESHING,
MANUAL_REFRESHING
}

public static Builder builder() {
return ImmutableIcebergInstructions.builder();
}
Expand All @@ -47,8 +53,8 @@ public static Builder builder() {
public abstract Map<String, String> columnRenames();

@Value.Default
public Boolean isRefreshing() {
return false;
public IcebergRefreshing refreshing() {
return IcebergRefreshing.STATIC;
}

public interface Builder {
Expand All @@ -65,7 +71,7 @@ public interface Builder {
Builder putAllColumnRenames(Map<String, ? extends String> entries);

@SuppressWarnings("unused")
Builder isRefreshing(Boolean isRefreshing);
Builder refreshing(IcebergRefreshing refreshing);

IcebergInstructions build();
}
Expand Down

0 comments on commit 264fdb1

Please sign in to comment.