From 402bdbe10cf7386edbf2900ad7b3c6d13110fe6e Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Mon, 23 Jan 2023 11:35:24 +0100 Subject: [PATCH 1/6] Fix field name typo in TestCreateMaterializedViewTask --- .../trino/execution/TestCreateMaterializedViewTask.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/trino-main/src/test/java/io/trino/execution/TestCreateMaterializedViewTask.java b/core/trino-main/src/test/java/io/trino/execution/TestCreateMaterializedViewTask.java index fa5c0ae42485..bf073a6feb3c 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestCreateMaterializedViewTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestCreateMaterializedViewTask.java @@ -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() @@ -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(); @@ -320,7 +320,7 @@ public void createMaterializedView(Session session, QualifiedObjectName viewName public Optional getCatalogHandle(Session session, String catalogName) { if (TEST_CATALOG_NAME.equals(catalogName)) { - return Optional.of(testCatlogHandle); + return Optional.of(testCatalogHandle); } return Optional.empty(); } @@ -337,7 +337,7 @@ public Optional getTableHandle(Session session, QualifiedObjectName if (tableName.asSchemaTableName().equals(MOCK_TABLE.getTable())) { return Optional.of( new TableHandle( - testCatlogHandle, + testCatalogHandle, new TestingTableHandle(tableName.asSchemaTableName()), TestingConnectorTransactionHandle.INSTANCE)); } From 75440e5476adb8378478c1977c179d4a66cddadb Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Wed, 25 Jan 2023 14:48:12 +0100 Subject: [PATCH 2/6] Add @Language annotation in AbstractTestQueryFramework --- .../java/io/trino/testing/AbstractTestQueryFramework.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestQueryFramework.java b/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestQueryFramework.java index a06d5ff82f0f..ddecb597a112 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestQueryFramework.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestQueryFramework.java @@ -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() @@ -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() From 0e00df7e7c52dc9120192dc42e6fe86a19c89c3a Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Wed, 25 Jan 2023 14:35:31 +0100 Subject: [PATCH 3/6] Fix code indentation --- .../trino/sql/analyzer/StatementAnalyzer.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java b/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java index d1c77fe68921..fc71a330ffd1 100644 --- a/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java +++ b/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java @@ -618,9 +618,9 @@ protected Scope visitInsert(Insert insert, Optional 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)); @@ -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)); @@ -1180,10 +1180,10 @@ protected Scope visitTableExecute(TableExecute node, Optional 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()); @@ -2775,15 +2775,15 @@ protected Scope visitSampledRelation(SampledRelation relation, Optional s } Map, 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)); From e463c195f512187b2512148fee547fc785378c85 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Mon, 23 Jan 2023 12:02:36 +0100 Subject: [PATCH 4/6] Remove legacy MaterializedViewFreshness constructor --- .../src/main/java/io/trino/testing/TestingMetadata.java | 4 +++- .../src/test/java/io/trino/connector/MockConnector.java | 4 +++- .../io/trino/spi/connector/MaterializedViewFreshness.java | 8 -------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/testing/TestingMetadata.java b/core/trino-main/src/main/java/io/trino/testing/TestingMetadata.java index f4c74af43983..46320df3c19d 100644 --- a/core/trino-main/src/main/java/io/trino/testing/TestingMetadata.java +++ b/core/trino-main/src/main/java/io/trino/testing/TestingMetadata.java @@ -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; @@ -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) diff --git a/core/trino-main/src/test/java/io/trino/connector/MockConnector.java b/core/trino-main/src/test/java/io/trino/connector/MockConnector.java index c7172aa870a7..9ec751bf48d4 100644 --- a/core/trino-main/src/test/java/io/trino/connector/MockConnector.java +++ b/core/trino-main/src/test/java/io/trino/connector/MockConnector.java @@ -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; @@ -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 diff --git a/core/trino-spi/src/main/java/io/trino/spi/connector/MaterializedViewFreshness.java b/core/trino-spi/src/main/java/io/trino/spi/connector/MaterializedViewFreshness.java index f9d2177aa26a..ce120d660b21 100644 --- a/core/trino-spi/src/main/java/io/trino/spi/connector/MaterializedViewFreshness.java +++ b/core/trino-spi/src/main/java/io/trino/spi/connector/MaterializedViewFreshness.java @@ -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"); From 7911367ec81e95e8c319c3c5d11b50a0ada30ec8 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Thu, 26 Jan 2023 09:57:46 +0100 Subject: [PATCH 5/6] empty From 429748a771b4ed9ca0fb66377a36e27d37245659 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Thu, 26 Jan 2023 14:04:53 +0100 Subject: [PATCH 6/6] empty