Skip to content

Commit d4ced37

Browse files
authored
Revert "[Kernel] [CC Refactor #1] Add TableIdentifier API (delta-io#3795)" (delta-io#3900)
This reverts commit 024dadb. We seem to be rethinking our Coordinated Commits CUJ / APIs, and we don't want these APIs leaked in Delta 3.3.
1 parent 510c170 commit d4ced37

File tree

4 files changed

+21
-160
lines changed

4 files changed

+21
-160
lines changed

kernel/kernel-api/src/main/java/io/delta/kernel/Table.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import io.delta.kernel.exceptions.TableNotFoundException;
2323
import io.delta.kernel.internal.TableImpl;
2424
import java.io.IOException;
25-
import java.util.Optional;
2625

2726
/**
2827
* Represents the Delta Lake table for a given path.
@@ -58,24 +57,6 @@ static Table forPath(Engine engine, String path) {
5857
return TableImpl.forPath(engine, path);
5958
}
6059

61-
/**
62-
* Instantiate a table object for the Delta Lake table at the given path and associate it with the
63-
* given {@link TableIdentifier}.
64-
*
65-
* <p>See {@link #forPath(Engine, String)} for more details on behavior when the table path does
66-
* or does not exist.
67-
*
68-
* @param engine the {@link Engine} instance to use in Delta Kernel.
69-
* @param path location of the table. Path is resolved to fully qualified path using the given
70-
* {@code engine}.
71-
* @param tableId the {@link TableIdentifier} to associate with the {@link Table}
72-
* @return an instance of {@link Table} representing the Delta table at the given path and
73-
* associated with the given {@link TableIdentifier}
74-
*/
75-
static Table forPathWithTableId(Engine engine, String path, TableIdentifier tableId) {
76-
return TableImpl.forPathWithTableId(engine, path, tableId);
77-
}
78-
7960
/**
8061
* The fully qualified path of this {@link Table} instance.
8162
*
@@ -85,14 +66,6 @@ static Table forPathWithTableId(Engine engine, String path, TableIdentifier tabl
8566
*/
8667
String getPath(Engine engine);
8768

88-
/**
89-
* The table identifier of this {@link Table} instance.
90-
*
91-
* @return the table identifier, or {@link Optional#empty()} if none is set.
92-
* @since 3.3.0
93-
*/
94-
Optional<TableIdentifier> getTableIdentifier();
95-
9669
/**
9770
* Get the latest snapshot of the table.
9871
*

kernel/kernel-api/src/main/java/io/delta/kernel/internal/TableImpl.java

Lines changed: 18 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@
4444

4545
public class TableImpl implements Table {
4646

47-
//////////////////////////////
48-
// Static Methods / Members //
49-
//////////////////////////////
50-
5147
private static final Logger logger = LoggerFactory.getLogger(TableImpl.class);
5248

5349
public static Table forPath(Engine engine, String path) {
@@ -64,60 +60,34 @@ public static Table forPath(Engine engine, String path) {
6460
* @return an instance of {@link Table} representing the Delta table at the given path
6561
*/
6662
public static Table forPath(Engine engine, String path, Clock clock) {
67-
return forPathWithTableId(engine, path, Optional.empty(), clock);
68-
}
69-
70-
public static Table forPathWithTableId(Engine engine, String path, TableIdentifier tableId) {
71-
return forPathWithTableId(engine, path, Optional.of(tableId), System::currentTimeMillis);
72-
}
73-
74-
public static Table forPathWithTableId(
75-
Engine engine, String path, Optional<TableIdentifier> tableIdOpt, Clock clock) {
63+
String resolvedPath;
7664
try {
77-
final String resolvedPath =
65+
resolvedPath =
7866
wrapEngineExceptionThrowsIO(
7967
() -> engine.getFileSystemClient().resolvePath(path), "Resolving path %s", path);
80-
return new TableImpl(resolvedPath, tableIdOpt, clock);
8168
} catch (IOException io) {
8269
throw new UncheckedIOException(io);
8370
}
71+
return new TableImpl(resolvedPath, clock);
8472
}
8573

86-
////////////////////////////////
87-
// Instance Methods / Members //
88-
////////////////////////////////
89-
74+
private final SnapshotManager snapshotManager;
9075
private final String tablePath;
91-
private final Optional<TableIdentifier> tableIdOpt;
9276
private final Clock clock;
9377

94-
private final Path dataPath;
95-
private final Path logPath;
96-
private final SnapshotManager snapshotManager;
97-
98-
private TableImpl(String tablePath, Optional<TableIdentifier> tableIdOpt, Clock clock) {
78+
public TableImpl(String tablePath, Clock clock) {
9979
this.tablePath = tablePath;
100-
this.tableIdOpt = tableIdOpt;
101-
this.clock = clock;
102-
this.dataPath = new Path(tablePath);
103-
this.logPath = new Path(dataPath, "_delta_log");
80+
final Path dataPath = new Path(tablePath);
81+
final Path logPath = new Path(dataPath, "_delta_log");
10482
this.snapshotManager = new SnapshotManager(logPath, dataPath);
83+
this.clock = clock;
10584
}
10685

107-
/////////////////
108-
// Public APIs //
109-
/////////////////
110-
11186
@Override
11287
public String getPath(Engine engine) {
11388
return tablePath;
11489
}
11590

116-
@Override
117-
public Optional<TableIdentifier> getTableIdentifier() {
118-
return tableIdOpt;
119-
}
120-
12191
@Override
12292
public Snapshot getLatestSnapshot(Engine engine) throws TableNotFoundException {
12393
return snapshotManager.buildLatestSnapshot(engine);
@@ -199,7 +169,8 @@ public CloseableIterator<ColumnarBatch> getChanges(
199169
for (int rowId = 0; rowId < protocolVector.getSize(); rowId++) {
200170
if (!protocolVector.isNullAt(rowId)) {
201171
Protocol protocol = Protocol.fromColumnVector(protocolVector, rowId);
202-
TableFeatures.validateReadSupportedTable(protocol, tablePath, Optional.empty());
172+
TableFeatures.validateReadSupportedTable(
173+
protocol, getDataPath().toString(), Optional.empty());
203174
}
204175
}
205176
if (shouldDropProtocolColumn) {
@@ -210,6 +181,14 @@ public CloseableIterator<ColumnarBatch> getChanges(
210181
});
211182
}
212183

184+
protected Path getDataPath() {
185+
return new Path(tablePath);
186+
}
187+
188+
protected Path getLogPath() {
189+
return new Path(tablePath, "_delta_log");
190+
}
191+
213192
/**
214193
* Returns the latest version that was committed before or at {@code millisSinceEpochUTC}. If no
215194
* version exists, throws a {@link KernelException}
@@ -290,22 +269,6 @@ public long getVersionAtOrAfterTimestamp(Engine engine, long millisSinceEpochUTC
290269
}
291270
}
292271

293-
////////////////////
294-
// Protected APIs //
295-
////////////////////
296-
297-
protected Path getDataPath() {
298-
return dataPath;
299-
}
300-
301-
protected Path getLogPath() {
302-
return logPath;
303-
}
304-
305-
////////////////////////////
306-
// Private Helper Methods //
307-
////////////////////////////
308-
309272
/**
310273
* Returns the raw delta actions for each version between startVersion and endVersion. Only reads
311274
* the actions requested in actionSet from the JSON log files.

kernel/kernel-api/src/test/scala/io/delta/kernel/TableIdentifierSuite.scala

Lines changed: 0 additions & 75 deletions
This file was deleted.

kernel/kernel-defaults/src/test/scala/io/delta/kernel/defaults/InCommitTimestampSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class InCommitTimestampSuite extends DeltaTableWriteSuiteBase {
236236

237237
test("Enablement tracking works when ICT is enabled post commit 0") {
238238
withTempDirAndEngine { (tablePath, engine) =>
239-
val table = Table.forPath(engine, tablePath)
239+
val table = TableImpl.forPath(engine, tablePath)
240240
val txnBuilder = table.createTransactionBuilder(engine, testEngineInfo, CREATE_TABLE)
241241

242242
val txn = txnBuilder
@@ -319,7 +319,7 @@ class InCommitTimestampSuite extends DeltaTableWriteSuiteBase {
319319

320320
test("Metadata toString should work with ICT enabled") {
321321
withTempDirAndEngine { (tablePath, engine) =>
322-
val table = Table.forPath(engine, tablePath)
322+
val table = TableImpl.forPath(engine, tablePath)
323323
val txnBuilder = table.createTransactionBuilder(engine, testEngineInfo, CREATE_TABLE)
324324

325325
val txn = txnBuilder
@@ -356,7 +356,7 @@ class InCommitTimestampSuite extends DeltaTableWriteSuiteBase {
356356

357357
test("Table with ICT enabled is readable") {
358358
withTempDirAndEngine { (tablePath, engine) =>
359-
val table = Table.forPath(engine, tablePath)
359+
val table = TableImpl.forPath(engine, tablePath)
360360
val txnBuilder = table.createTransactionBuilder(engine, testEngineInfo, CREATE_TABLE)
361361

362362
val txn = txnBuilder

0 commit comments

Comments
 (0)