One approach is to extend BaseTable and HadoopTableOperations classes.

public static class IcebergTable extends BaseTable {
  private final IcebergTableOperations ops;

  private IcebergTable(IcebergTableOperations ops, String name) {
    super(ops, name);
    this.ops = ops;
  }

  IcebergTableOperations ops() {
    return ops;
  }
}


public class IcebergTableOperations extends HadoopTableOperations {
  public IcebergTableOperations(Path location, Configuration conf) {
    super(location, conf);
  }
}


Wrapper function can be written to create an Iceberg table using above
extended classes.

Once we have instances of above classes pointing to Iceberg table,
following should work


        IcebergTable table = createIcebergTableWrapper(SCHEMA, spec,
tableLocation);

        TableMetadata base = table.ops().current();

        table.ops().commit(base, base.updatePartitionSpec(newSpec));


Note that method, table.ops() is available on specialized IcebergTable
class.



On Fri, Oct 25, 2019 at 9:51 PM Christine Mathiesen <t-cmathie...@hotels.com>
wrote:

> Hey Iceberg devs!
>
> I've been following along the discussion about how the partition spec
> evolution in Iceberg works, and recently I've been trying to implement this
> in some code I've been writing. However, I've been trying to implement it
> using the HadoopTables API and haven't been able to figure it out.
>
> From what I've been reading I would expect this operation to look
> something like:
>
>         Table table = tables.create(SCHEMA, spec,
> tableLocation);
>
>         TableMetadata base = table.operations.current();
>
>         base.updatePartitionSpec(newSpec);
>
>         table.refresh();
>
> However, I'm not finding a way of accessing and modifying this table
> metadata when trying to use HadoopTables. Schema evolution has a nice
> UpdateSchema class for this, but am I missing something for the partition
> evolution side?
>
> Would anyone be able to point me in the right direction?
>
> Thank you!
>
>
>
>
>
> *Christine Mathiesen *
>
> Software Development Intern
>
> BDP – Hotels.com
>
> Expedia Group
>
>
>


-- 
Best regards
T.Vamsi Kalyan
+91-94905 56669

Reply via email to