[
https://issues.apache.org/jira/browse/BEAM-5112?focusedWorklogId=179564&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-179564
]
ASF GitHub Bot logged work on BEAM-5112:
----------------------------------------
Author: ASF GitHub Bot
Created on: 28/Dec/18 20:50
Start Date: 28/Dec/18 20:50
Worklog Time Spent: 10m
Work Description: apilloud commented on pull request #6417: [BEAM-5112]
Use Calcite codegen to implement BeamCalcRel
URL: https://github.com/apache/beam/pull/6417#discussion_r244405355
##########
File path:
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamCalcRel.java
##########
@@ -68,15 +121,90 @@ public Calc copy(RelTraitSet traitSet, RelNode input,
RexProgram program) {
BeamCalcRel.class.getSimpleName(),
pinput);
PCollection<Row> upstream = pinput.get(0);
+ Schema outputSchema = CalciteUtils.toSchema(getRowType());
+
+ final SqlConformance conformance = SqlConformanceEnum.MYSQL_5;
+ final JavaTypeFactory typeFactory =
+ new JavaTypeFactoryImpl(BeamRelDataTypeSystem.INSTANCE) {
+ @Override
+ public Type getJavaClass(RelDataType type) {
+ if (type instanceof BasicSqlType || type instanceof
IntervalSqlType) {
+ if (type.getSqlTypeName() == SqlTypeName.FLOAT) {
+ return type.isNullable() ? Float.class : float.class;
+ }
+ }
+ return super.getJavaClass(type);
+ }
+ };
+ final BlockBuilder builder = new BlockBuilder();
+
+ final PhysType physType =
+ PhysTypeImpl.of(typeFactory, getRowType(), JavaRowFormat.ARRAY,
false);
+
+ Expression input =
+ Expressions.convert_(Expressions.call(processContextParam,
"element"), Row.class);
+
+ final RexBuilder rexBuilder = getCluster().getRexBuilder();
+ final RelMetadataQuery mq = RelMetadataQuery.instance();
+ final RelOptPredicateList predicates =
mq.getPulledUpPredicates(getInput());
+ final RexSimplify simplify = new RexSimplify(rexBuilder, predicates,
false, RexUtil.EXECUTOR);
+ final RexProgram program =
BeamCalcRel.this.program.normalize(rexBuilder, simplify);
- BeamSqlExpressionExecutor executor = new
BeamSqlFnExecutor(BeamCalcRel.this.getProgram());
+ Expression condition =
+ RexToLixTranslator.translateCondition(
Review comment:
It should be always safe to call. It validates the program has a condition
and if not emits 'true'. The code generator will optimize away 'if (true)'
before generating the java code.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 179564)
Time Spent: 3h 40m (was: 3.5h)
> Investigate if Calcite can generate functions that we need
> ----------------------------------------------------------
>
> Key: BEAM-5112
> URL: https://issues.apache.org/jira/browse/BEAM-5112
> Project: Beam
> Issue Type: Sub-task
> Components: dsl-sql
> Reporter: Rui Wang
> Assignee: Andrew Pilloud
> Priority: Major
> Time Spent: 3h 40m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)