Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
"nullness" // TODO(https://issues.apache.org/jira/browse/BEAM-10402)
})
public class ZetaSQLQueryPlanner implements QueryPlanner {
public static final Collection<RelOptRule> DEFAULT_CALC =
ImmutableList.<RelOptRule>builder()
.add(BeamZetaSqlCalcRule.INSTANCE)
.add(BeamJavaUdfCalcRule.INSTANCE)
.build();

private static final Logger LOG = LoggerFactory.getLogger(ZetaSQLQueryPlanner.class);

private final ZetaSQLPlannerImpl plannerImpl;
Expand All @@ -95,7 +101,8 @@ public ZetaSQLQueryPlanner(FrameworkConfig config) {
*/
public ZetaSQLQueryPlanner(JdbcConnection jdbcConnection, Collection<RuleSet> ruleSets) {
plannerImpl =
new ZetaSQLPlannerImpl(defaultConfig(jdbcConnection, modifyRuleSetsForZetaSql(ruleSets)));
new ZetaSQLPlannerImpl(
defaultConfig(jdbcConnection, modifyRuleSetsForZetaSql(ruleSets, DEFAULT_CALC)));
setDefaultTimezone(
jdbcConnection
.getPipelineOptions()
Expand All @@ -113,7 +120,11 @@ public QueryPlanner createPlanner(
};

public static Collection<RuleSet> getZetaSqlRuleSets() {
return modifyRuleSetsForZetaSql(BeamRuleSets.getRuleSets());
return modifyRuleSetsForZetaSql(BeamRuleSets.getRuleSets(), DEFAULT_CALC);
}

public static Collection<RuleSet> getZetaSqlRuleSets(Collection<RelOptRule> calc) {
return modifyRuleSetsForZetaSql(BeamRuleSets.getRuleSets(), calc);
}

/**
Expand Down Expand Up @@ -178,7 +189,8 @@ static boolean hasNoJavaUdfInProjects(RelOptRuleCall x) {
return true;
}

private static Collection<RuleSet> modifyRuleSetsForZetaSql(Collection<RuleSet> ruleSets) {
private static Collection<RuleSet> modifyRuleSetsForZetaSql(
Collection<RuleSet> ruleSets, Collection<RelOptRule> calc) {
ImmutableList.Builder<RuleSet> ret = ImmutableList.builder();
for (RuleSet ruleSet : ruleSets) {
ImmutableList.Builder<RelOptRule> bd = ImmutableList.builder();
Expand All @@ -196,8 +208,7 @@ private static Collection<RuleSet> modifyRuleSetsForZetaSql(Collection<RuleSet>
// planning result eventually.
continue;
} else if (rule instanceof BeamCalcRule) {
bd.add(BeamZetaSqlCalcRule.INSTANCE);
bd.add(BeamJavaUdfCalcRule.INSTANCE);
bd.addAll(calc);
} else if (rule instanceof BeamUnnestRule) {
bd.add(BeamZetaSqlUnnestRule.INSTANCE);
} else if (rule instanceof BeamUncollectRule) {
Expand Down