Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RetryMode to ConnectorTableFunction.analyze + minor changes in Hive connector #20756

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static io.trino.SystemSessionProperties.getMaxGroupingSets;
import static io.trino.SystemSessionProperties.getRetryPolicy;
import static io.trino.SystemSessionProperties.isLegacyMaterializedViewGracePeriod;
import static io.trino.metadata.FunctionResolver.toPath;
import static io.trino.metadata.GlobalFunctionCatalog.isBuiltinFunctionName;
Expand Down Expand Up @@ -1679,7 +1680,8 @@ protected Scope visitTableFunctionInvocation(TableFunctionInvocation node, Optio
session.toConnectorSession(catalogHandle),
transactionHandle,
argumentsAnalysis.getPassedArguments(),
new InjectedConnectorAccessControl(accessControl, session.toSecurityContext(), catalogHandle.getCatalogName()));
new InjectedConnectorAccessControl(accessControl, session.toSecurityContext(), catalogHandle.getCatalogName()),
getRetryPolicy(session).getRetryMode());

List<List<String>> copartitioningLists = analyzeCopartitioning(node.getCopartitioning(), argumentsAnalysis.getTableArgumentAnalyses());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.trino.spi.connector.ConnectorAccessControl;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.connector.ConnectorTransactionHandle;
import io.trino.spi.connector.RetryMode;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -49,4 +50,9 @@ public interface ConnectorTableFunction
* @param arguments actual invocation arguments, mapped by argument names
*/
TableFunctionAnalysis analyze(ConnectorSession session, ConnectorTransactionHandle transaction, Map<String, Argument> arguments, ConnectorAccessControl accessControl);

default TableFunctionAnalysis analyze(ConnectorSession session, ConnectorTransactionHandle transaction, Map<String, Argument> arguments, ConnectorAccessControl accessControl, RetryMode retryMode)
{
return analyze(session, transaction, arguments, accessControl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.trino.spi.connector.ConnectorAccessControl;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.connector.ConnectorTransactionHandle;
import io.trino.spi.connector.RetryMode;
import io.trino.spi.function.table.Argument;
import io.trino.spi.function.table.ArgumentSpecification;
import io.trino.spi.function.table.ConnectorTableFunction;
Expand Down Expand Up @@ -82,4 +83,17 @@ public TableFunctionAnalysis analyze(ConnectorSession session,
return delegate.analyze(session, transaction, arguments, accessControl);
}
}

@Override
public TableFunctionAnalysis analyze(
ConnectorSession session,
ConnectorTransactionHandle transaction,
Map<String, Argument> arguments,
ConnectorAccessControl accessControl,
RetryMode retryMode)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.analyze(session, transaction, arguments, accessControl, retryMode);
}
}
}
6 changes: 6 additions & 0 deletions plugin/trino-hive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-filesystem-gcs</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-filesystem-s3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3770,15 +3770,7 @@ private static void validateColumns(ConnectorTableMetadata tableMetadata)
// Validate the name and the type of each column
for (ColumnMetadata column : tableMetadata.getColumns()) {
String columnName = column.getName();
if (columnName.startsWith(" ")) {
throw new TrinoException(NOT_SUPPORTED, format("Hive column names must not start with a space: '%s'", columnName));
}
if (columnName.endsWith(" ")) {
throw new TrinoException(NOT_SUPPORTED, format("Hive column names must not end with a space: '%s'", columnName));
}
if (columnName.contains(",")) {
throw new TrinoException(NOT_SUPPORTED, format("Hive column names must not contain commas: '%s'", columnName));
}
verifyHiveColumnName(columnName);
// validate type is supported
toHiveType(column.getType());
}
Expand All @@ -3801,6 +3793,19 @@ private static void validateColumns(ConnectorTableMetadata tableMetadata)
}
}

public static void verifyHiveColumnName(String columnName)
{
if (columnName.startsWith(" ")) {
throw new TrinoException(NOT_SUPPORTED, format("Hive column names must not start with a space: '%s'", columnName));
}
if (columnName.endsWith(" ")) {
throw new TrinoException(NOT_SUPPORTED, format("Hive column names must not end with a space: '%s'", columnName));
}
if (columnName.contains(",")) {
throw new TrinoException(NOT_SUPPORTED, format("Hive column names must not contain commas: '%s'", columnName));
}
}

private static void validateTimestampColumns(List<ColumnMetadata> columns, HiveTimestampPrecision precision)
{
for (ColumnMetadata column : columns) {
Expand Down
Loading