kennknowles commented on a change in pull request #11820:
URL: https://github.com/apache/beam/pull/11820#discussion_r435597049



##########
File path: 
sdks/java/testing/nexmark/src/main/java/org/apache/beam/sdk/nexmark/queries/zetasql/ZetaSqlQuery0.java
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.nexmark.queries.zetasql;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.extensions.sql.SqlTransform;
+import org.apache.beam.sdk.extensions.sql.zetasql.ZetaSQLQueryPlanner;
+import org.apache.beam.sdk.metrics.Counter;
+import org.apache.beam.sdk.metrics.Metrics;
+import org.apache.beam.sdk.nexmark.model.Bid;
+import org.apache.beam.sdk.nexmark.model.Event;
+import org.apache.beam.sdk.nexmark.model.Event.Type;
+import org.apache.beam.sdk.nexmark.model.sql.SelectEvent;
+import org.apache.beam.sdk.nexmark.queries.NexmarkQueryTransform;
+import org.apache.beam.sdk.nexmark.queries.NexmarkQueryUtil;
+import org.apache.beam.sdk.schemas.transforms.Convert;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.Filter;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.transforms.ParDo;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.Row;
+
+/**
+ * Query 0: Pass events through unchanged.
+ *
+ * <p>This measures the overhead of the Beam ZetaSql implementation and test 
harness like conversion
+ * from Java model classes to Beam records.
+ *
+ * <p>{@link Bid} events are used here at the moment, ås they are most 
numerous with default
+ * configuration.
+ */
+public class ZetaSqlQuery0 extends NexmarkQueryTransform<Bid> {
+
+  public ZetaSqlQuery0() {
+    super("ZetaSqlQuery0");
+  }
+
+  @Override
+  public PCollection<Bid> expand(PCollection<Event> allEvents) {
+    PCollection<Row> rows =
+        allEvents
+            .apply(Filter.by(NexmarkQueryUtil.IS_BID))
+            .apply(getName() + ".SelectEvent", new SelectEvent(Type.BID));
+
+    return rows.apply(getName() + ".Serialize", 
logBytesMetric(rows.getCoder()))
+        .setRowSchema(rows.getSchema())
+        .apply(
+            SqlTransform.query("SELECT * FROM PCOLLECTION")
+                .withQueryPlannerClass(ZetaSQLQueryPlanner.class))

Review comment:
       In my mental model, there are _n_ Nexmark queries with common setup and 
teardown, and then there are _m_ suites that implement the queries, filling in 
the middle part. I do want to keep them slightly decoupled in case some of them 
need hackery. They turned out not to require tweaking, but I'm not super 
convinced that isn't coincidence.
   
   So the refactor I have in mind is to provide the scaffolding for each query 
but still having a pure java, Calcite, and ZetaSQL suite of classes. The 
Calcite and ZetaSQL bits would share a lot and/or be one liners.




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


Reply via email to