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

Small code fixes #15843

Merged
merged 6 commits into from
Jan 26, 2023
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 @@ -618,9 +618,9 @@ protected Scope visitInsert(Insert insert, Optional<Scope> scope)
targetTable,
Optional.empty(),
Optional.of(Streams.zip(
columnStream,
queryScope.getRelationType().getVisibleFields().stream(),
(column, field) -> new OutputColumn(column, analysis.getSourceColumns(field)))
columnStream,
queryScope.getRelationType().getVisibleFields().stream(),
(column, field) -> new OutputColumn(column, analysis.getSourceColumns(field)))
.collect(toImmutableList())));

return createAndAssignScope(insert, scope, Field.newUnqualified("rows", BIGINT));
Expand Down Expand Up @@ -701,9 +701,9 @@ protected Scope visitRefreshMaterializedView(RefreshMaterializedView refreshMate
targetTable,
Optional.empty(),
Optional.of(Streams.zip(
columns,
queryScope.getRelationType().getVisibleFields().stream(),
(column, field) -> new OutputColumn(column, analysis.getSourceColumns(field)))
columns,
queryScope.getRelationType().getVisibleFields().stream(),
(column, field) -> new OutputColumn(column, analysis.getSourceColumns(field)))
.collect(toImmutableList())));

return createAndAssignScope(refreshMaterializedView, scope, Field.newUnqualified("rows", BIGINT));
Expand Down Expand Up @@ -1180,10 +1180,10 @@ protected Scope visitTableExecute(TableExecute node, Optional<Scope> scope)

TableExecuteHandle executeHandle =
metadata.getTableHandleForExecute(
session,
tableHandle,
procedureName,
tableProperties)
session,
tableHandle,
procedureName,
tableProperties)
.orElseThrow(() -> semanticException(NOT_SUPPORTED, node, "Procedure '%s' cannot be executed on table '%s'", procedureName, tableName));

analysis.setTableExecuteReadsData(procedureMetadata.getExecutionMode().isReadsData());
Expand Down Expand Up @@ -2775,15 +2775,15 @@ protected Scope visitSampledRelation(SampledRelation relation, Optional<Scope> s
}

Map<NodeRef<Expression>, Type> expressionTypes = ExpressionAnalyzer.analyzeExpressions(
session,
plannerContext,
statementAnalyzerFactory,
accessControl,
TypeProvider.empty(),
ImmutableList.of(samplePercentage),
analysis.getParameters(),
WarningCollector.NOOP,
analysis.getQueryType())
session,
plannerContext,
statementAnalyzerFactory,
accessControl,
TypeProvider.empty(),
ImmutableList.of(samplePercentage),
analysis.getParameters(),
WarningCollector.NOOP,
analysis.getQueryType())
.getExpressionTypes();

Type samplePercentageType = expressionTypes.get(NodeRef.of(samplePercentage));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static io.trino.spi.StandardErrorCode.ALREADY_EXISTS;
import static io.trino.spi.connector.MaterializedViewFreshness.Freshness.FRESH;
import static io.trino.spi.connector.MaterializedViewFreshness.Freshness.STALE;
import static java.util.Collections.synchronizedSet;
import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -269,7 +271,7 @@ public void dropMaterializedView(ConnectorSession session, SchemaTableName viewN
@Override
public MaterializedViewFreshness getMaterializedViewFreshness(ConnectorSession session, SchemaTableName name)
{
return new MaterializedViewFreshness(freshMaterializedViews.contains(name));
return new MaterializedViewFreshness(freshMaterializedViews.contains(name) ? FRESH : STALE);
}

public void markMaterializedViewIsFresh(SchemaTableName name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static io.trino.connector.MockConnector.MockConnectorSplit.MOCK_CONNECTOR_SPLIT;
import static io.trino.spi.connector.MaterializedViewFreshness.Freshness.FRESH;
import static io.trino.spi.connector.MaterializedViewFreshness.Freshness.STALE;
import static io.trino.spi.connector.RowChangeParadigm.DELETE_ROW_AND_INSERT_ROW;
import static io.trino.spi.type.BigintType.BIGINT;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -592,7 +594,7 @@ public MaterializedViewFreshness getMaterializedViewFreshness(ConnectorSession s
{
ConnectorMaterializedViewDefinition view = getMaterializedViews.apply(session, viewName.toSchemaTablePrefix()).get(viewName);
checkArgument(view != null, "Materialized view %s does not exist", viewName);
return new MaterializedViewFreshness(view.getStorageTable().isPresent());
return new MaterializedViewFreshness(view.getStorageTable().isPresent() ? FRESH : STALE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class TestCreateMaterializedViewTask
private AnalyzerFactory analyzerFactory;
private MaterializedViewPropertyManager materializedViewPropertyManager;
private LocalQueryRunner queryRunner;
private CatalogHandle testCatlogHandle;
private CatalogHandle testCatalogHandle;

@BeforeMethod
public void setUp()
Expand All @@ -136,7 +136,7 @@ public void setUp()
.build())
.build(),
ImmutableMap.of());
testCatlogHandle = queryRunner.getCatalogHandle(TEST_CATALOG_NAME);
testCatalogHandle = queryRunner.getCatalogHandle(TEST_CATALOG_NAME);

materializedViewPropertyManager = queryRunner.getMaterializedViewPropertyManager();

Expand Down Expand Up @@ -320,7 +320,7 @@ public void createMaterializedView(Session session, QualifiedObjectName viewName
public Optional<CatalogHandle> getCatalogHandle(Session session, String catalogName)
{
if (TEST_CATALOG_NAME.equals(catalogName)) {
return Optional.of(testCatlogHandle);
return Optional.of(testCatalogHandle);
}
return Optional.empty();
}
Expand All @@ -337,7 +337,7 @@ public Optional<TableHandle> getTableHandle(Session session, QualifiedObjectName
if (tableName.asSchemaTableName().equals(MOCK_TABLE.getTable())) {
return Optional.of(
new TableHandle(
testCatlogHandle,
testCatalogHandle,
new TestingTableHandle(tableName.asSchemaTableName()),
TestingConnectorTransactionHandle.INSTANCE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,12 @@
import java.util.Objects;
import java.util.StringJoiner;

import static io.trino.spi.connector.MaterializedViewFreshness.Freshness.FRESH;
import static io.trino.spi.connector.MaterializedViewFreshness.Freshness.STALE;
import static java.util.Objects.requireNonNull;

public final class MaterializedViewFreshness
{
private final Freshness freshness;

@Deprecated
public MaterializedViewFreshness(boolean materializedViewFresh)
{
this(materializedViewFresh ? FRESH : STALE);
}

public MaterializedViewFreshness(Freshness freshness)
{
this.freshness = requireNonNull(freshness, "freshness is null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,13 @@ protected void executeExclusively(Runnable executionBlock)
}
}

protected String formatSqlText(String sql)
protected String formatSqlText(@Language("SQL") String sql)
{
return formatSql(SQL_PARSER.createStatement(sql, createParsingOptions(getSession())));
}

//TODO: should WarningCollector be added?
protected String getExplainPlan(String query, ExplainType.Type planType)
protected String getExplainPlan(@Language("SQL") String query, ExplainType.Type planType)
{
QueryExplainer explainer = queryRunner.getQueryExplainer();
return newTransaction()
Expand All @@ -558,7 +558,7 @@ protected String getExplainPlan(String query, ExplainType.Type planType)
});
}

protected String getGraphvizExplainPlan(String query, ExplainType.Type planType)
protected String getGraphvizExplainPlan(@Language("SQL") String query, ExplainType.Type planType)
{
QueryExplainer explainer = queryRunner.getQueryExplainer();
return newTransaction()
Expand Down