beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (BEAM-5112) Investigate if Calcite can generate functions that we need
Date Tue, 25 Sep 2018 13:53:00 GMT

     [ https://issues.apache.org/jira/browse/BEAM-5112?focusedWorklogId=147575&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-147575
]

ASF GitHub Bot logged work on BEAM-5112:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 25/Sep/18 13:52
            Start Date: 25/Sep/18 13:52
    Worklog Time Spent: 10m 
      Work Description: akedin commented on a change in pull request #6417: [BEAM-5112] Use
Calcite codegen to implement BeamCalcRel
URL: https://github.com/apache/beam/pull/6417#discussion_r220199073
 
 

 ##########
 File path: sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamCalcRel.java
 ##########
 @@ -68,15 +119,128 @@ 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 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);
+
+      Expression condition =
+          RexToLixTranslator.translateCondition(
+              program,
+              typeFactory,
+              builder,
+              new InputGetterImpl(input, upstream.getSchema()),
+              null);
+
+      List<Expression> expressions =
+          RexToLixTranslator.translateProjects(
+              program,
+              typeFactory,
+              builder,
+              physType,
+              DataContext.ROOT,
+              new InputGetterImpl(input, upstream.getSchema()),
+              null);
+      assert expressions.size() == outputSchema.getFieldCount();
 
 Review comment:
   should this be an exception?

----------------------------------------------------------------
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:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 147575)

> 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: 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message