You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/09/09 20:09:35 UTC

[GitHub] [beam] ibzib commented on a change in pull request #15486: [BEAM-12691] FieldAccessDescriptor for BeamCalcRel

ibzib commented on a change in pull request #15486:
URL: https://github.com/apache/beam/pull/15486#discussion_r705649798



##########
File path: sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamCalcRel.java
##########
@@ -207,20 +204,28 @@ public Calc copy(RelTraitSet traitSet, RelNode input, RexProgram program) {
     private final Schema outputSchema;
     private final boolean verifyRowValues;
     private final List<String> jarPaths;
+
+    @FieldAccess("row")
+    private final FieldAccessDescriptor fieldAccess;
+
     private transient @Nullable ScriptEvaluator se = null;
 
     public CalcFn(
         String processElementBlock,
         Schema outputSchema,
         boolean verifyRowValues,
-        List<String> jarPaths) {
+        List<String> jarPaths,
+        FieldAccessDescriptor fieldAccess) {
       this.processElementBlock = processElementBlock;
       this.outputSchema = outputSchema;
       this.verifyRowValues = verifyRowValues;
       this.jarPaths = jarPaths;
+      this.fieldAccess = fieldAccess;
+
+      compile(processElementBlock, jarPaths);

Review comment:
       We should keep the comment to explain why we do this.

##########
File path: sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/BeamZetaSqlCalcRel.java
##########
@@ -190,10 +193,22 @@ private static TimestampedFuture create(Instant t, Future<Value> f) {
       this.outputSchema = outputSchema;
       this.defaultTimezone = defaultTimezone;
       this.verifyRowValues = verifyRowValues;
+
+      PreparedExpression exp = prepareExpression(sql, nullParams, inputSchema, defaultTimezone);
+
+      ImmutableList.Builder<Integer> columns = new ImmutableList.Builder<>();
+      for (String c : exp.getReferencedColumns()) {
+        columns.add(Integer.parseInt(c.substring(1)));
+      }
+      this.referencedColumns = columns.build();
+      this.fieldAccess = FieldAccessDescriptor.withFieldIds(this.referencedColumns);
+
+      exp.close();

Review comment:
       PreparedExpression implements AutoCloseable, so we can use a try-with-resources block instead.




-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org