aokolnychyi commented on a change in pull request #1409:
URL: https://github.com/apache/iceberg/pull/1409#discussion_r481397074
##########
File path: api/src/main/java/org/apache/iceberg/catalog/Catalog.java
##########
@@ -303,4 +304,105 @@ default boolean dropTable(TableIdentifier identifier) {
* @throws NoSuchTableException if the table does not exist
*/
Table loadTable(TableIdentifier identifier);
+
+ /**
+ * Instantiate a builder to create a table.
+ *
+ * @param identifier a table identifier
+ * @param schema a schema
+ * @return the builder to create a table
+ */
+ default Builder newTable(TableIdentifier identifier, Schema schema) {
+ return new Builder(this, identifier, schema);
+ }
+
+ /**
+ * A builder used to create valid {@link Table tables}.
+ * <p>
+ * Call {@link #newTable(TableIdentifier, Schema)} to create a new builder.
+ */
+ class Builder {
+ private final Catalog catalog;
+ private final TableIdentifier identifier;
+ private final Schema schema;
+ private final Map<String, String> properties = new HashMap<>();
+ private PartitionSpec spec = PartitionSpec.unpartitioned();
+ private String location = null;
+
+ private Builder(Catalog catalog, TableIdentifier identifier, Schema
schema) {
+ this.catalog = catalog;
+ this.identifier = identifier;
+ this.schema = schema;
+ }
+
+ /**
+ * Sets a partition spec for the table.
+ *
+ * @param newSpec a partition spec
+ * @return this for method chaining
+ */
+ public Builder withPartitionSpec(PartitionSpec newSpec) {
+ this.spec = newSpec;
+ return this;
+ }
+
+ /**
+ * Sets a location for the table.
+ *
+ * @param newLocation a location
+ * @return this for method chaining
+ */
+ public Builder withLocation(String newLocation) {
+ this.location = newLocation;
+ return this;
+ }
+
+ /**
+ * Adds a key/value property to the table.
+ *
+ * @param key a key
+ * @param value a value
+ * @return this for method chaining
+ */
+ public Builder withProperty(String key, String value) {
Review comment:
We probably need to expose `withProperties` that accepts a map.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]