Skip to content

Commit 40742dc

Browse files
committed
[Iceberg]Accept and maintain autocommit context on starting transaction
1 parent cd3eeda commit 40742dc

File tree

7 files changed

+31
-9
lines changed

7 files changed

+31
-9
lines changed

presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ public abstract class IcebergAbstractMetadata
223223
protected Transaction transaction;
224224
protected final StatisticsFileCache statisticsFileCache;
225225
protected final IcebergTableProperties tableProperties;
226+
protected final boolean autoCommitContext;
226227

227228
private final StandardFunctionResolution functionResolution;
228229
private final ConcurrentMap<SchemaTableName, Table> icebergTables = new ConcurrentHashMap<>();
@@ -235,7 +236,8 @@ public IcebergAbstractMetadata(
235236
NodeVersion nodeVersion,
236237
FilterStatsCalculatorService filterStatsCalculatorService,
237238
StatisticsFileCache statisticsFileCache,
238-
IcebergTableProperties tableProperties)
239+
IcebergTableProperties tableProperties,
240+
boolean autoCommitContext)
239241
{
240242
this.typeManager = requireNonNull(typeManager, "typeManager is null");
241243
this.commitTaskCodec = requireNonNull(commitTaskCodec, "commitTaskCodec is null");
@@ -245,6 +247,7 @@ public IcebergAbstractMetadata(
245247
this.filterStatsCalculatorService = requireNonNull(filterStatsCalculatorService, "filterStatsCalculatorService is null");
246248
this.statisticsFileCache = requireNonNull(statisticsFileCache, "statisticsFileCache is null");
247249
this.tableProperties = requireNonNull(tableProperties, "tableProperties is null");
250+
this.autoCommitContext = autoCommitContext;
248251
}
249252

250253
protected final Table getIcebergTable(ConnectorSession session, SchemaTableName schemaTableName)

presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergConnector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ public ConnectorAccessControl getAccessControl()
184184
}
185185

186186
@Override
187-
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly)
187+
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean autoCommitContext, boolean readOnly)
188188
{
189189
checkConnectorSupports(SERIALIZABLE, isolationLevel);
190190
ConnectorTransactionHandle transaction = new HiveTransactionHandle();
191191
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(getClass().getClassLoader())) {
192-
transactionManager.put(transaction, metadataFactory.create());
192+
transactionManager.put(transaction, metadataFactory.create(autoCommitContext));
193193
}
194194
return transaction;
195195
}

presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,11 @@ public IcebergHiveMetadata(
180180
StatisticsFileCache statisticsFileCache,
181181
ManifestFileCache manifestFileCache,
182182
IcebergTableProperties tableProperties,
183-
ConnectorSystemConfig connectorSystemConfig)
183+
ConnectorSystemConfig connectorSystemConfig,
184+
boolean autoCommitContext)
184185
{
185-
super(typeManager, functionResolution, rowExpressionService, commitTaskCodec, nodeVersion, filterStatsCalculatorService, statisticsFileCache, tableProperties);
186+
super(typeManager, functionResolution, rowExpressionService, commitTaskCodec, nodeVersion,
187+
filterStatsCalculatorService, statisticsFileCache, tableProperties, autoCommitContext);
186188
this.catalogName = requireNonNull(catalogName, "catalogName is null");
187189
this.metastore = requireNonNull(metastore, "metastore is null");
188190
this.hdfsEnvironment = requireNonNull(hdfsEnvironment, "hdfsEnvironment is null");

presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadataFactory.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public IcebergHiveMetadataFactory(
8181
}
8282

8383
public ConnectorMetadata create()
84+
{
85+
return create(true);
86+
}
87+
88+
public ConnectorMetadata create(boolean autoCommitContext)
8489
{
8590
return new IcebergHiveMetadata(
8691
catalogName,
@@ -96,6 +101,7 @@ public ConnectorMetadata create()
96101
statisticsFileCache,
97102
manifestFileCache,
98103
tableProperties,
99-
connectorSystemConfig);
104+
connectorSystemConfig,
105+
autoCommitContext);
100106
}
101107
}

presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergMetadataFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@
1818
public interface IcebergMetadataFactory
1919
{
2020
ConnectorMetadata create();
21+
22+
ConnectorMetadata create(boolean autoCommitContext);
2123
}

presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergNativeMetadata.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ public IcebergNativeMetadata(
108108
NodeVersion nodeVersion,
109109
FilterStatsCalculatorService filterStatsCalculatorService,
110110
StatisticsFileCache statisticsFileCache,
111-
IcebergTableProperties tableProperties)
111+
IcebergTableProperties tableProperties,
112+
boolean autoCommitContext)
112113
{
113-
super(typeManager, functionResolution, rowExpressionService, commitTaskCodec, nodeVersion, filterStatsCalculatorService, statisticsFileCache, tableProperties);
114+
super(typeManager, functionResolution, rowExpressionService, commitTaskCodec, nodeVersion,
115+
filterStatsCalculatorService, statisticsFileCache, tableProperties, autoCommitContext);
114116
this.catalogFactory = requireNonNull(catalogFactory, "catalogFactory is null");
115117
this.catalogType = requireNonNull(catalogType, "catalogType is null");
116118
this.warehouseDataDir = Optional.ofNullable(catalogFactory.getCatalogWarehouseDataDir());

presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergNativeMetadataFactory.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ public IcebergNativeMetadataFactory(
6868

6969
public ConnectorMetadata create()
7070
{
71-
return new IcebergNativeMetadata(catalogFactory, typeManager, functionResolution, rowExpressionService, commitTaskCodec, catalogType, nodeVersion, filterStatsCalculatorService, statisticsFileCache, tableProperties);
71+
return create(true);
72+
}
73+
74+
public ConnectorMetadata create(boolean autoCommitContext)
75+
{
76+
return new IcebergNativeMetadata(catalogFactory, typeManager, functionResolution,
77+
rowExpressionService, commitTaskCodec, catalogType, nodeVersion,
78+
filterStatsCalculatorService, statisticsFileCache, tableProperties, autoCommitContext);
7279
}
7380
}

0 commit comments

Comments
 (0)