-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of version metadata table for view #12014
base: main
Are you sure you want to change the base?
Changes from all commits
3634259
dfc92f4
6280020
8094e52
737c4dc
df552e6
19863e3
9757316
7c1296f
ed319fa
b456118
22d8def
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import org.apache.iceberg.encryption.EncryptionManager; | ||
import org.apache.iceberg.io.FileIO; | ||
import org.apache.iceberg.io.LocationProvider; | ||
import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | ||
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; | ||
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; | ||
import org.apache.iceberg.view.BaseView; | ||
import org.apache.iceberg.view.View; | ||
import org.apache.iceberg.view.ViewOperations; | ||
|
||
public abstract class BaseViewMetadataTable extends BaseReadOnlyTable implements Serializable { | ||
|
||
// TODO: refactor and share same code as BaseMetadataTable | ||
private final PartitionSpec spec = PartitionSpec.unpartitioned(); | ||
|
||
private final SortOrder sortOrder = SortOrder.unsorted(); | ||
private final BaseView view; | ||
private final String name; | ||
private final UUID uuid; | ||
|
||
protected BaseViewMetadataTable(View view, String name) { | ||
super("metadata"); | ||
Preconditions.checkArgument( | ||
view instanceof BaseView, "Cannot create metadata table for view: %s", view); | ||
this.view = (BaseView) view; | ||
this.name = name; | ||
this.uuid = UUID.randomUUID(); | ||
} | ||
|
||
protected ViewOperations operations() { | ||
return view.operations(); | ||
} | ||
|
||
@Override | ||
public void refresh() { | ||
view.operations().refresh(); | ||
} | ||
|
||
@Override | ||
public PartitionSpec spec() { | ||
return spec; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public FileIO io() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String location() { | ||
return view.location(); | ||
} | ||
|
||
@Override | ||
public EncryptionManager encryption() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public LocationProvider locationProvider() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Map<Integer, Schema> schemas() { | ||
return ImmutableMap.of(TableMetadata.INITIAL_SCHEMA_ID, schema()); | ||
} | ||
|
||
@Override | ||
public Map<Integer, PartitionSpec> specs() { | ||
return ImmutableMap.of(spec.specId(), spec); | ||
} | ||
|
||
@Override | ||
public SortOrder sortOrder() { | ||
return sortOrder; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no sort order for view, this shouldn't be included. |
||
} | ||
|
||
@Override | ||
public Map<Integer, SortOrder> sortOrders() { | ||
return ImmutableMap.of(sortOrder.orderId(), sortOrder); | ||
} | ||
|
||
@Override | ||
public Map<String, String> properties() { | ||
return ImmutableMap.of(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Views have properties, we should be exposing them. |
||
} | ||
|
||
@Override | ||
public Snapshot currentSnapshot() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Iterable<Snapshot> snapshots() { | ||
return ImmutableList.of(); | ||
} | ||
|
||
@Override | ||
public Snapshot snapshot(long snapshotId) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<HistoryEntry> history() { | ||
return ImmutableList.of(); | ||
} | ||
|
||
@Override | ||
public List<StatisticsFile> statisticsFiles() { | ||
return ImmutableList.of(); | ||
} | ||
|
||
@Override | ||
public List<PartitionStatisticsFile> partitionStatisticsFiles() { | ||
return ImmutableList.of(); | ||
} | ||
|
||
@Override | ||
public Map<String, SnapshotRef> refs() { | ||
return ImmutableMap.of(); | ||
} | ||
Comment on lines
+118
to
+151
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these are not handled properly (similar to above) |
||
|
||
@Override | ||
public UUID uuid() { | ||
return uuid; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name(); | ||
} | ||
|
||
final Object writeReplace() { | ||
return SerializableTable.copyOf(this); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg; | ||
|
||
import org.apache.iceberg.util.PropertyUtil; | ||
|
||
abstract class BaseViewMetadataTableScan extends BaseTableScan { | ||
|
||
private final ViewMetadataTableType tableType; | ||
|
||
protected BaseViewMetadataTableScan(Table table, Schema schema, ViewMetadataTableType tableType) { | ||
super(table, schema, TableScanContext.empty()); | ||
this.tableType = tableType; | ||
} | ||
|
||
protected BaseViewMetadataTableScan( | ||
Table table, Schema schema, ViewMetadataTableType tableType, TableScanContext context) { | ||
super(table, schema, context); | ||
this.tableType = tableType; | ||
} | ||
|
||
@Override | ||
public TableScan appendsBetween(long fromSnapshotId, long toSnapshotId) { | ||
throw new UnsupportedOperationException( | ||
String.format("Cannot incrementally scan table of type %s", tableType)); | ||
} | ||
|
||
@Override | ||
public TableScan appendsAfter(long fromSnapshotId) { | ||
throw new UnsupportedOperationException( | ||
String.format("Cannot incrementally scan table of type %s", tableType)); | ||
} | ||
|
||
@Override | ||
public long targetSplitSize() { | ||
return PropertyUtil.propertyAsLong( | ||
options(), TableProperties.SPLIT_SIZE, TableProperties.METADATA_SPLIT_SIZE_DEFAULT); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty much all methods that aren't supported by views should be throwing a
UnsupportedOperationException
(similar to how it's done in the super classThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, we should remove all of the concrete implementations that are returning null here.