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

Refactor ScanOperator to eliminate variability #375

Merged
merged 5 commits into from
Sep 27, 2021

Conversation

HangyuanLiu
Copy link
Contributor

@HangyuanLiu HangyuanLiu force-pushed the logical-scan branch 3 times, most recently from fc707fd to f734302 Compare September 24, 2021 12:18
@HangyuanLiu
Copy link
Contributor Author

run starrocks_fe_unittest

.collect(Collectors.toSet());
scanColumns.addAll(Utils.extractColumnRef(scanOperator.getPredicate()));

if (scanColumns.size() == 0 || scanOperator.getPartitionColumns().containsAll(scanColumns)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need comment

int smallestIndex = -1;
int smallestColumnLength = Integer.MAX_VALUE;
for (int index = 0; index < outputColumns.size(); ++index) {
if (scanOperator.getPartitionColumns().contains(outputColumns.get(index).getName())) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need comment

starRocksAssert.withMaterializedView(createEmpsMVSQL);
//.query(query).explainContains(QUERY_USE_EMPS_MV, 2);

System.out.println("FIXME : " + starRocksAssert.query(query).explainQuery());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@@ -488,7 +488,10 @@ public void testUnionAll() throws Exception {
EMPS_TABLE_NAME + " order by empid, deptno;";
String query = "select empid, deptno from " + EMPS_TABLE_NAME + " where empid >1 union all select empid,"
+ " deptno from " + EMPS_TABLE_NAME + " where empid <0;";
starRocksAssert.withMaterializedView(createEmpsMVSQL).query(query).explainContains(QUERY_USE_EMPS_MV, 2);
starRocksAssert.withMaterializedView(createEmpsMVSQL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactor shouldn't change the UT result

@@ -465,9 +467,10 @@ public void testRollUp() throws Exception {
public void testMV() throws Exception {
String sql = "select count(distinct k7), count(distinct k8) from duplicate_table_with_null;";
String planFragment = getFragmentPlan(sql);
System.out.println("FIXME : " + planFragment);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@@ -980,4 +984,13 @@ public void testJoinProjectRewrite() throws Exception {
query = "select approx_count_distinct(salary) from emps left outer join depts on emps.time = depts.time";
starRocksAssert.query(query).explainContains("emps_mv");
}

@Test
public void test1() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a concrete name

((LogicalOlapScanOperator) scanOperator).getDistributionSpec(),
scanOperator.getLimit(),
scanOperator.getPredicate());
newScanOperator.setSelectedIndexId(olapScanOperator.getSelectedIndexId());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why still call set method here?

.collect(Collectors.toSet());
scanOutputColumns.addAll(Utils.extractColumnRef(scanOperator.getPredicate()));
scanOperator.tryExtendOutputColumns(scanOutputColumns);
Set<ColumnRefOperator> outputColumns =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should keep the comment

Comment on lines 278 to 280
new LogicalEsScanOperator(node.getTable(), outputVariables, colRefToColumnMetaMap.build(),
columnMetaToColRefMap, -1,
null);
Copy link
Contributor

@Seaven Seaven Sep 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. -1 can be replace to DEFAULT_NONE_LIMIT or NONE_LIMIT
  2. Most operator don't need set limit/predicate, canbe support a construnct method don't give limit/predicate

By the way, I think support builder mode(like Statistics.Builder) will make it easier to use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1、There are too many modified codes at present, exceeding the limit of a review. I can submit another PR to modify this question
2、Can be provided, such as the first build in relationTransformer, but I do not recommend using this constructor

Seaven
Seaven previously approved these changes Sep 26, 2021
@@ -214,10 +219,10 @@ public OptExprBuilder visitValues(ValuesRelation node, ExpressionMapping context

@Override
public OptExprBuilder visitTable(TableRelation node, ExpressionMapping context) {
ImmutableMap.Builder<ColumnRefOperator, Column> columns = ImmutableMap.builder();
ImmutableMap.Builder<ColumnRefOperator, Column> colRefToColumnMetaMap = ImmutableMap.builder();
ImmutableMap.Builder<Column, ColumnRefOperator> columnToIds = ImmutableMap.builder();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not to id, can change a new name

@@ -56,8 +56,4 @@ public ColumnRefSet getUsedColumns() {

return result;
}

public abstract boolean equals(Object o);
Copy link
Contributor

@Youngwb Youngwb Sep 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep may be better, others may forget implements these method when extends this class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equal has been implemented in the parent class according to predicate and limit, and the subclass needs to implement its own function according to its own class attributes

@kangkaisen kangkaisen merged commit 46285e0 into StarRocks:main Sep 27, 2021
@HangyuanLiu HangyuanLiu deleted the logical-scan branch November 5, 2021 02:12
caneGuy pushed a commit to caneGuy/starrocks that referenced this pull request Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants