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/12/08 18:46:13 UTC

[GitHub] [beam] lostluck commented on a change in pull request #16111: WIP [BEAM-13293] XLang Jdbc IO for Go SDK

lostluck commented on a change in pull request #16111:
URL: https://github.com/apache/beam/pull/16111#discussion_r765139544



##########
File path: sdks/go/test/integration/io/xlang/jdbc/jdbc.go
##########
@@ -0,0 +1,62 @@
+// 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 jdbc contains integration tests for cross-language JDBC IO transforms.
+
+package jdbc
+
+import (
+	"reflect"
+
+	"github.com/apache/beam/sdks/v2/go/pkg/beam"
+	"github.com/apache/beam/sdks/v2/go/pkg/beam/io/xlang/jdbcio"
+)
+
+func init() {
+	beam.RegisterType(reflect.TypeOf((*JdbcWriteTestRow)(nil)).Elem())
+}
+
+type JdbcWriteTestRow struct {
+	F_id string `beam:F_id`
+}
+
+// writeList encodes a list of ints and sends encoded ints to Kafka.
+func writeRows(s beam.Scope, expansionAddr, tableName, driverClassName, jdbcUrl, username, password string, rows beam.PCollection) {
+	s = s.Scope("jdbc_test.WriteToJdbc")
+	jdbcio.Write(s, expansionAddr, tableName, driverClassName, jdbcUrl, username, password, rows) //, jdbcio.WriteStatement(statement))
+}
+
+// WritePipeline creates a pipeline that writes a given slice of ints to Kafka.
+func WritePipeline(expansionAddr, tableName, driverClassName, jdbcUrl, username, password string) *beam.Pipeline {
+	beam.Init()
+	p, s := beam.NewPipelineWithRoot()
+	rows := []JdbcWriteTestRow{{"row1"}, {"row2"}}
+
+	writeRows(s, expansionAddr, tableName, driverClassName, jdbcUrl, username, password, beam.Create(s, rows))

Review comment:
       The following should resolve the coder issue in https://issues.apache.org/jira/browse/BEAM-13418
   
   ```suggestion
   	input :=  beam.CreateList(s, rows)
   	writeRows(s, expansionAddr, tableName, driverClassName, jdbcUrl, username, password, input)
   ```




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