Skip to content

Commit

Permalink
Remove deprecated TableScanNode.newInstance()
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe committed Nov 8, 2024
1 parent d89e230 commit 9a50464
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import io.trino.spi.connector.ColumnHandle;
import io.trino.spi.connector.ColumnMetadata;
import io.trino.spi.connector.ConnectorTableMetadata;
import io.trino.spi.predicate.TupleDomain;
import io.trino.spi.security.AccessDeniedException;
import io.trino.spi.statistics.TableStatistics;
import io.trino.spi.statistics.TableStatisticsMetadata;
Expand Down Expand Up @@ -435,7 +436,7 @@ private RelationPlan createAnalyzePlan(Analysis analysis, Analyze analyzeStateme
idAllocator.getNextId(),
singleAggregation(
idAllocator.getNextId(),
TableScanNode.newInstance(idAllocator.getNextId(), targetTable, tableScanOutputs.build(), symbolToColumnHandle.buildOrThrow(), false, Optional.empty()),
new TableScanNode(idAllocator.getNextId(), targetTable, tableScanOutputs.build(), symbolToColumnHandle.buildOrThrow(), TupleDomain.all(), Optional.empty(), false, Optional.empty()),
statisticAggregations.getAggregations(),
singleGroupingSet(groupingSymbols)),
new StatisticsWriterNode.WriteStatisticsReference(targetTable),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.trino.operator.table.json.JsonTableValueColumn;
import io.trino.spi.connector.ColumnHandle;
import io.trino.spi.function.table.TableArgument;
import io.trino.spi.predicate.TupleDomain;
import io.trino.spi.type.RowType;
import io.trino.spi.type.Type;
import io.trino.sql.PlannerContext;
Expand Down Expand Up @@ -337,7 +338,7 @@ protected RelationPlan visitTable(Table node, Void context)

List<Symbol> outputSymbols = outputSymbolsBuilder.build();
boolean updateTarget = analysis.isUpdateTarget(node);
PlanNode root = TableScanNode.newInstance(idAllocator.getNextId(), handle, outputSymbols, columns.buildOrThrow(), updateTarget, Optional.empty());
PlanNode root = new TableScanNode(idAllocator.getNextId(), handle, outputSymbols, columns.buildOrThrow(), TupleDomain.all(), Optional.empty(), updateTarget, Optional.empty());

plan = new RelationPlan(root, scope, outputSymbols, outerContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,6 @@ public class TableScanNode
private final boolean updateTarget;
private final Optional<Boolean> useConnectorNodePartitioning;

/**
* @deprecated Use explicit constructor instead. Calling this method when transforming the plan may lead to information loss.
*/
// We need this factory method to disambiguate with the constructor used for deserializing
// from a json object. The deserializer sets some fields which are never transported
// to null
@Deprecated
public static TableScanNode newInstance(
PlanNodeId id,
TableHandle table,
List<Symbol> outputs,
Map<Symbol, ColumnHandle> assignments,
boolean updateTarget,
Optional<Boolean> useConnectorNodePartitioning)
{
return new TableScanNode(id, table, outputs, assignments, TupleDomain.all(), Optional.empty(), updateTarget, useConnectorNodePartitioning);
}

@DoNotCall // For JSON serialization only
@JsonCreator
public static TableScanNode fromJson(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.ImmutableLongArray;
import io.trino.spi.predicate.TupleDomain;
import io.trino.sql.planner.Partitioning;
import io.trino.sql.planner.PartitioningScheme;
import io.trino.sql.planner.PlanFragment;
Expand Down Expand Up @@ -116,7 +117,7 @@ private PlanFragment createPlanFragment(StatsAndCosts statsAndCosts)
{
return new PlanFragment(
new PlanFragmentId("fragment"),
TableScanNode.newInstance(
new TableScanNode(
new PlanNodeId("plan_id"),
TEST_TABLE_HANDLE,
ImmutableList.of(new Symbol(VARCHAR, "col_a"), new Symbol(VARCHAR, "col_b"), new Symbol(BIGINT, "col_c"), new Symbol(DOUBLE, "col_d")),
Expand All @@ -125,6 +126,8 @@ private PlanFragment createPlanFragment(StatsAndCosts statsAndCosts)
new Symbol(VARCHAR, "col_b"), new TestingColumnHandle("col_b", 1, VARCHAR),
new Symbol(BIGINT, "col_c"), new TestingColumnHandle("col_c", 2, BIGINT),
new Symbol(DOUBLE, "col_d"), new TestingColumnHandle("col_d", 3, DOUBLE)),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty()),
ImmutableSet.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import io.trino.metadata.Split;
import io.trino.operator.TaskContext;
import io.trino.operator.TaskStats;
import io.trino.spi.predicate.TupleDomain;
import io.trino.spiller.SpillSpaceTracker;
import io.trino.sql.planner.Partitioning;
import io.trino.sql.planner.PartitioningScheme;
Expand Down Expand Up @@ -110,11 +111,13 @@ public MockRemoteTask createTableScanTask(TaskId taskId, InternalNode newNode, L
PlanNodeId sourceId = new PlanNodeId("sourceId");
PlanFragment testFragment = new PlanFragment(
new PlanFragmentId("test"),
TableScanNode.newInstance(
new TableScanNode(
sourceId,
TEST_TABLE_HANDLE,
ImmutableList.of(symbol),
ImmutableMap.of(symbol, new TestingColumnHandle("column")),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty()),
ImmutableSet.of(symbol),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import io.trino.server.protocol.spooling.QueryDataEncoders;
import io.trino.server.protocol.spooling.SpoolingEnabledConfig;
import io.trino.spi.connector.CatalogHandle;
import io.trino.spi.predicate.TupleDomain;
import io.trino.spiller.GenericSpillerFactory;
import io.trino.split.PageSinkManager;
import io.trino.split.PageSourceManager;
Expand Down Expand Up @@ -95,11 +96,13 @@ private TaskTestUtils() {}

public static final PlanFragment PLAN_FRAGMENT = new PlanFragment(
new PlanFragmentId("fragment"),
TableScanNode.newInstance(
new TableScanNode(
TABLE_SCAN_NODE_ID,
TEST_TABLE_HANDLE,
ImmutableList.of(SYMBOL),
ImmutableMap.of(SYMBOL, new TestingColumnHandle("column", 0, BIGINT)),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty()),
ImmutableSet.of(SYMBOL),
Expand All @@ -119,11 +122,13 @@ private TaskTestUtils() {}
new PlanFragmentId("fragment"),
new DynamicFilterSourceNode(
new PlanNodeId("dynamicFilterSource"),
TableScanNode.newInstance(
new TableScanNode(
TABLE_SCAN_NODE_ID,
TEST_TABLE_HANDLE,
ImmutableList.of(SYMBOL),
ImmutableMap.of(SYMBOL, new TestingColumnHandle("column", 0, BIGINT)),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty()),
ImmutableMap.of(DYNAMIC_FILTER_SOURCE_ID, SYMBOL)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,22 +523,26 @@ private PlanFragment createFragment(TableHandle firstTableHandle, TableHandle se
Symbol symbol = new Symbol(VARCHAR, "column");
Symbol buildSymbol = new Symbol(VARCHAR, "buildColumn");

TableScanNode tableScanOne = TableScanNode.newInstance(
TableScanNode tableScanOne = new TableScanNode(
TABLE_SCAN_1_NODE_ID,
firstTableHandle,
ImmutableList.of(symbol),
ImmutableMap.of(symbol, new TestingColumnHandle("column")),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty());
FilterNode filterNodeOne = new FilterNode(
new PlanNodeId("filter_node_id"),
tableScanOne,
createDynamicFilterExpression(createTestMetadataManager(), DYNAMIC_FILTER_ID, VARCHAR, symbol.toSymbolReference()));
TableScanNode tableScanTwo = TableScanNode.newInstance(
TableScanNode tableScanTwo = new TableScanNode(
TABLE_SCAN_2_NODE_ID,
secondTableHandle,
ImmutableList.of(symbol),
ImmutableMap.of(symbol, new TestingColumnHandle("column")),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty());
FilterNode filterNodeTwo = new FilterNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.trino.metadata.InMemoryNodeManager;
import io.trino.metadata.InternalNode;
import io.trino.metadata.Split;
import io.trino.spi.predicate.TupleDomain;
import io.trino.sql.planner.Partitioning;
import io.trino.sql.planner.PartitioningScheme;
import io.trino.sql.planner.PlanFragment;
Expand Down Expand Up @@ -385,11 +386,13 @@ private static PlanFragment createFragment()
Symbol symbol = new Symbol(UNKNOWN, "column");

// table scan with splitCount splits
TableScanNode tableScan = TableScanNode.newInstance(
TableScanNode tableScan = new TableScanNode(
TABLE_SCAN_NODE_ID,
TEST_TABLE_HANDLE,
ImmutableList.of(symbol),
ImmutableMap.of(symbol, new TestingMetadata.TestingColumnHandle("column")),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,13 @@ private static PlanFragment createFragment()
Symbol buildSymbol = new Symbol(VARCHAR, "buildColumn");

// table scan with splitCount splits
TableScanNode tableScan = TableScanNode.newInstance(
TableScanNode tableScan = new TableScanNode(
TABLE_SCAN_NODE_ID,
TEST_TABLE_HANDLE,
ImmutableList.of(symbol),
ImmutableMap.of(symbol, new TestingColumnHandle("column")),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty());
FilterNode filterNode = new FilterNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.google.common.collect.ImmutableSet;
import io.trino.cost.StatsAndCosts;
import io.trino.operator.RetryPolicy;
import io.trino.spi.predicate.TupleDomain;
import io.trino.sql.planner.Partitioning;
import io.trino.sql.planner.PartitioningScheme;
import io.trino.sql.planner.PlanFragment;
Expand Down Expand Up @@ -69,11 +70,13 @@ static PlanFragment createAggregationFragment(String name, PlanFragment sourceFr
static PlanFragment createBroadcastJoinPlanFragment(String name, PlanFragment buildFragment)
{
Symbol symbol = new Symbol(UNKNOWN, "column");
PlanNode tableScan = TableScanNode.newInstance(
PlanNode tableScan = new TableScanNode(
new PlanNodeId(name),
TEST_TABLE_HANDLE,
ImmutableList.of(symbol),
ImmutableMap.of(symbol, new TestingMetadata.TestingColumnHandle("column")),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty());

Expand Down Expand Up @@ -174,11 +177,13 @@ static PlanFragment createBroadcastAndPartitionedJoinPlanFragment(
static PlanFragment createTableScanPlanFragment(String name)
{
Symbol symbol = new Symbol(UNKNOWN, "column");
PlanNode planNode = TableScanNode.newInstance(
PlanNode planNode = new TableScanNode(
new PlanNodeId(name),
TEST_TABLE_HANDLE,
ImmutableList.of(symbol),
ImmutableMap.of(symbol, new TestingMetadata.TestingColumnHandle("column")),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,11 +1023,13 @@ private static PlanFragment createPlan(
Symbol buildSymbol = new Symbol(VARCHAR, "buildColumn");

PlanNodeId tableScanNodeId = new PlanNodeId("plan_id");
TableScanNode tableScan = TableScanNode.newInstance(
TableScanNode tableScan = new TableScanNode(
tableScanNodeId,
TEST_TABLE_HANDLE,
ImmutableList.of(symbol),
ImmutableMap.of(symbol, new TestingMetadata.TestingColumnHandle("column")),
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty());
FilterNode filterNode = new FilterNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@ public void setUp()
.buildOrThrow();

Map<Symbol, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(new Symbol(BIGINT, "a"), new Symbol(BIGINT, "b"), new Symbol(BIGINT, "c"), new Symbol(BIGINT, "d"), new Symbol(BIGINT, "e"), new Symbol(BIGINT, "f"))));
baseTableScan = TableScanNode.newInstance(
baseTableScan = new TableScanNode(
newId(),
makeTableHandle(TupleDomain.all()),
ImmutableList.copyOf(assignments.keySet()),
assignments,
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty());

Expand Down Expand Up @@ -432,11 +434,13 @@ public void testTableScan()
{
// Effective predicate is True if there is no effective predicate
Map<Symbol, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(new Symbol(BIGINT, "a"), new Symbol(BIGINT, "b"), new Symbol(DOUBLE, "c"), new Symbol(REAL, "d"))));
PlanNode node = TableScanNode.newInstance(
PlanNode node = new TableScanNode(
newId(),
makeTableHandle(TupleDomain.all()),
ImmutableList.copyOf(assignments.keySet()),
assignments,
TupleDomain.all(),
Optional.empty(),
false,
Optional.empty());
Expression effectivePredicate = effectivePredicateExtractor.extract(SESSION, node);
Expand Down

0 comments on commit 9a50464

Please sign in to comment.