atoomula commented on a change in pull request #1384:
URL: https://github.com/apache/samza/pull/1384#discussion_r456932347
##########
File path:
samza-sql/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java
##########
@@ -140,16 +166,45 @@ public RelRoot plan(String query) {
.operatorTable(new ChainedSqlOperatorTable(sqlOperatorTables))
.sqlToRelConverterConfig(SqlToRelConverter.Config.DEFAULT)
.traitDefs(traitDefs)
- .context(Contexts.EMPTY_CONTEXT)
- .costFactory(null)
+ .programs(Programs.hep(rules, true,
DefaultRelMetadataProvider.INSTANCE))
.build();
- Planner planner = Frameworks.getPlanner(frameworkConfig);
+ planner = Frameworks.getPlanner(frameworkConfig);
+ return planner;
+ } catch (Exception e) {
+ String errorMsg = "Failed to create planner.";
+ LOG.error(errorMsg, e);
+ throw new SamzaException(errorMsg, e);
+ }
+ }
+ private RelRoot optimize(RelRoot relRoot) {
+ RelTraitSet relTraitSet = RelTraitSet.createEmpty();
+ try {
+ RelRoot optimizedRelRoot =
+ RelRoot.of(getPlanner().transform(0, relTraitSet,
relRoot.project()), SqlKind.SELECT);
+ LOG.info("query plan with optimization:\n"
Review comment:
1. \n is not for EOL. It is for separating the log.
2. You mean all log messages in Samza or just this ? And what is the point
of capitalizing ? Is it to catch the eye while going thru logs ? If yes, we
don't need to as their format makes them stand out in the logs,
2020-07-19 10:11:16.814 [main] [] QueryPlanner [INFO] query plan without
optimization:
LogicalProject(__key__=[$9], pageKey=[$9], companyName=['N/A'],
profileName=[$2], profileAddress=[$4])
LogicalFilter(condition=[AND(=($2, 'Mike'), =($10, 1))])
LogicalProject(__key__=[$0], id=[$1], name=[$2], companyId=[$3],
address=[$4], selfEmployed=[$5], phoneNumbers=[$6], mapValues=[$7],
__key__0=[$8], pageKey=[$9], profileId=[$10])
LogicalJoin(condition=[=($0, $11)], joinType=[inner])
LogicalTableScan(table=[[testRemoteStore, Profile, $table]])
LogicalProject(__key__=[$0], pageKey=[$1], profileId=[$2],
$f3=[BuildOutputRecord('id', $2)])
LogicalTableScan(table=[[testavro, PAGEVIEW]])
2020-07-19 10:11:16.816 [main] [] QueryPlanner [INFO] query plan with
optimization:
LogicalProject(__key__=[$9], pageKey=[$9], companyName=['N/A'],
profileName=[$2], profileAddress=[$4])
LogicalFilter(condition=[=($2, 'Mike')])
LogicalJoin(condition=[=($0, $11)], joinType=[inner])
LogicalTableScan(table=[[testRemoteStore, Profile, $table]])
LogicalFilter(condition=[=($2, 1)])
LogicalProject(__key__=[$0], pageKey=[$1], profileId=[$2],
$f3=[BuildOutputRecord('id', $2)])
LogicalTableScan(table=[[testavro, PAGEVIEW]])
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]