Skip to content

Commit

Permalink
Improve error message related to storage layers which allow write col…
Browse files Browse the repository at this point in the history
…lisions
  • Loading branch information
findinpath authored and findepi committed Nov 18, 2022
1 parent 6179a26 commit c28f676
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ public class DeltaLakeMetadata
.add(TOTAL_SIZE_IN_BYTES)
.add(NUMBER_OF_DISTINCT_VALUES_SUMMARY)
.build();
private static final String ENABLE_NON_CONCURRENT_WRITES_CONFIGURATION_KEY = "delta.enable-non-concurrent-writes";

private final DeltaLakeMetastore metastore;
private final TrinoFileSystemFactory fileSystemFactory;
Expand Down Expand Up @@ -1257,7 +1258,10 @@ public ConnectorInsertTableHandle beginInsert(ConnectorSession session, Connecto
DeltaLakeTableHandle table = (DeltaLakeTableHandle) tableHandle;
if (!allowWrite(session, table)) {
String fileSystem = new Path(table.getLocation()).toUri().getScheme();
throw new TrinoException(NOT_SUPPORTED, format("Inserts are not supported on the %s filesystem", fileSystem));
throw new TrinoException(
NOT_SUPPORTED,
format("Inserts are not enabled on the %1$s filesystem in order to avoid eventual data corruption which may be caused by concurrent data modifications on the table. " +
"Writes to the %1$s filesystem can be however enabled with the '%2$s' configuration property.", fileSystem, ENABLE_NON_CONCURRENT_WRITES_CONFIGURATION_KEY));
}
Map<String, String> columnInvariants = getColumnInvariants(table.getMetadataEntry());
if (!columnInvariants.isEmpty()) {
Expand Down Expand Up @@ -1395,7 +1399,10 @@ public ConnectorTableHandle beginDelete(ConnectorSession session, ConnectorTable
}
if (!allowWrite(session, handle)) {
String fileSystem = new Path(handle.getLocation()).toUri().getScheme();
throw new TrinoException(NOT_SUPPORTED, format("Deletes are not supported on the %s filesystem", fileSystem));
throw new TrinoException(
NOT_SUPPORTED,
format("Deletes are not enabled on the %1$s filesystem in order to avoid eventual data corruption which may be caused by concurrent data modifications on the table. " +
"Writes to the %1$s filesystem can be however enabled with the '%2$s' configuration property.", fileSystem, ENABLE_NON_CONCURRENT_WRITES_CONFIGURATION_KEY));
}
if (!getCheckConstraints(handle.getMetadataEntry()).isEmpty()) {
throw new TrinoException(NOT_SUPPORTED, "Writing to tables with CHECK constraints is not supported");
Expand Down Expand Up @@ -1457,7 +1464,10 @@ public ConnectorTableHandle beginUpdate(ConnectorSession session, ConnectorTable
}
if (!allowWrite(session, handle)) {
String fileSystem = new Path(handle.getLocation()).toUri().getScheme();
throw new TrinoException(NOT_SUPPORTED, format("Updates are not supported on the %s filesystem", fileSystem));
throw new TrinoException(
NOT_SUPPORTED,
format("Updates are not enabled on the %1$s filesystem in order to avoid eventual data corruption which may be caused by concurrent data modifications on the table. " +
"Writes to the %1$s filesystem can be however enabled with the '%2$s' configuration property.", fileSystem, ENABLE_NON_CONCURRENT_WRITES_CONFIGURATION_KEY));
}

Map<String, String> columnInvariants = getColumnInvariants(handle.getMetadataEntry());
Expand Down Expand Up @@ -1533,7 +1543,10 @@ public ConnectorMergeTableHandle beginMerge(ConnectorSession session, ConnectorT
}
if (!allowWrite(session, handle)) {
String fileSystem = new Path(handle.getLocation()).toUri().getScheme();
throw new TrinoException(NOT_SUPPORTED, format("Updates are not supported on the %s filesystem", fileSystem));
throw new TrinoException(
NOT_SUPPORTED,
format("Updates are not enabled on the %1$s filesystem in order to avoid eventual data corruption which may be caused by concurrent data modifications on the table. " +
"Writes to the %1$s filesystem can be however enabled with the '%2$s' configuration property.", fileSystem, ENABLE_NON_CONCURRENT_WRITES_CONFIGURATION_KEY));
}
if (!getColumnInvariants(handle.getMetadataEntry()).isEmpty()) {
throw new TrinoException(NOT_SUPPORTED, "Updates are not supported for tables with delta invariants");
Expand Down Expand Up @@ -1737,7 +1750,10 @@ private BeginTableExecuteResult<ConnectorTableExecuteHandle, ConnectorTableHandl

if (!allowWrite(session, table)) {
String fileSystem = new Path(table.getLocation()).toUri().getScheme();
throw new TrinoException(NOT_SUPPORTED, format("Optimize is not supported on the %s filesystem", fileSystem));
throw new TrinoException(
NOT_SUPPORTED,
format("Optimize is not enabled on the %1$s filesystem in order to avoid eventual data corruption which may be caused by concurrent data modifications on the table. " +
"Writes to the %1$s filesystem can be however enabled with the '%2$s' configuration property.", fileSystem, ENABLE_NON_CONCURRENT_WRITES_CONFIGURATION_KEY));
}
checkSupportedWriterVersion(session, table.getSchemaTableName());

Expand Down

0 comments on commit c28f676

Please sign in to comment.