-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
fc707fd
to
f734302
Compare
f734302
to
dbe44cd
Compare
run starrocks_fe_unittest |
.collect(Collectors.toSet()); | ||
scanColumns.addAll(Utils.extractColumnRef(scanOperator.getPredicate())); | ||
|
||
if (scanColumns.size() == 0 || scanOperator.getPartitionColumns().containsAll(scanColumns)) { |
There was a problem hiding this comment.
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())) { |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should keep the comment
new LogicalEsScanOperator(node.getTable(), outputVariables, colRefToColumnMetaMap.build(), | ||
columnMetaToColRefMap, -1, | ||
null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- -1 can be replace to DEFAULT_NONE_LIMIT or NONE_LIMIT
- 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?
There was a problem hiding this comment.
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
5dcc8f1
to
9e4fc26
Compare
9e4fc26
to
67d1b60
Compare
@@ -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(); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
#373