byronellis commented on code in PR #25177: URL: https://github.com/apache/beam/pull/25177#discussion_r1089608950
########## sdks/java/extensions/sql/expansion-service/src/main/java/org/apache/beam/sdk/extensions/sql/expansion/SqlTransformSchemaTransformProvider.java: ########## @@ -0,0 +1,233 @@ +/* + * 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.extensions.sql.expansion; + +import com.google.auto.service.AutoService; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.stream.Collectors; +import org.apache.beam.sdk.extensions.sql.SqlTransform; +import org.apache.beam.sdk.extensions.sql.impl.QueryPlanner; +import org.apache.beam.sdk.extensions.sql.meta.provider.TableProvider; +import org.apache.beam.sdk.schemas.Schema; +import org.apache.beam.sdk.schemas.logicaltypes.EnumerationType; +import org.apache.beam.sdk.schemas.logicaltypes.OneOfType; +import org.apache.beam.sdk.schemas.transforms.SchemaTransform; +import org.apache.beam.sdk.schemas.transforms.SchemaTransformProvider; +import org.apache.beam.sdk.transforms.PTransform; +import org.apache.beam.sdk.values.PCollection; +import org.apache.beam.sdk.values.PCollectionRowTuple; +import org.apache.beam.sdk.values.PDone; +import org.apache.beam.sdk.values.Row; +import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList; +import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap; +import org.checkerframework.checker.initialization.qual.Initialized; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.UnknownKeyFor; + +@AutoService(SchemaTransformProvider.class) +public class SqlTransformSchemaTransformProvider implements SchemaTransformProvider { + + private static final Map<String, Class<? extends QueryPlanner>> QUERY_PLANNERS = + ImmutableMap.of( + "zetasql", org.apache.beam.sdk.extensions.sql.zetasql.ZetaSQLQueryPlanner.class, + "calcite", org.apache.beam.sdk.extensions.sql.impl.CalciteQueryPlanner.class); + private static final EnumerationType QUERY_ENUMERATION = + EnumerationType.create(QUERY_PLANNERS.keySet().stream().collect(Collectors.toList())); + + private static final OneOfType QUERY_PARAMETER = + OneOfType.create( + Schema.Field.nullable("string", Schema.FieldType.STRING), + Schema.Field.nullable("short", Schema.FieldType.INT16), + Schema.Field.nullable("int", Schema.FieldType.INT32), + Schema.Field.nullable("long", Schema.FieldType.INT64), + Schema.Field.nullable("float", Schema.FieldType.FLOAT), + Schema.Field.nullable("double", Schema.FieldType.DOUBLE), + Schema.Field.nullable("datetime", Schema.FieldType.DATETIME)); + + @Override + public @UnknownKeyFor @NonNull @Initialized String identifier() { + return "schematransform:org.apache.beam:sql_transform:v1"; + } + + @Override + public @UnknownKeyFor @NonNull @Initialized Schema configurationSchema() { Review Comment: Oh good, went through and removed all that clutter -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
