我需要使用云调度程序中的随机/动态 job_names 触发 Google 数据流作业。我可以传递静态作业名称并通过将其传递到调度程序主体来触发数据流。有没有办法通过调度程序动态设置这个作业名称?
如果有办法设置 current_timestamp 或一些 random_numbers 会有帮助。
我知道我们也可以通过云功能触发数据流。但试图避免这里的服务数量。
我拥有的:
{ "job_name": "test-run-df-job" }
我需要的:
{ "job_name": "test-run-df-job" + CURRENT_TIME() }
感谢您的任何帮助。
google-cloud-platform google-cloud-dataflow google-cloud-scheduler
我正在尝试从 PubSub 读取消息,然后写入 DataFlow 中的 BigQuery 表。但是,我通过使用直接运行器遇到了“无根单位”错误。
这是我的代码;
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"github.com/apache/beam/sdks/v2/go/pkg/beam/io/bigqueryio"
"github.com/apache/beam/sdks/v2/go/pkg/beam/x/debug"
"github.com/apache/beam/sdks/v2/go/pkg/beam"
"github.com/apache/beam/sdks/v2/go/pkg/beam/io/pubsubio"
"github.com/apache/beam/sdks/v2/go/pkg/beam/log"
"github.com/apache/beam/sdks/v2/go/pkg/beam/x/beamx"
)
type DummyBody struct {
TaskId string `json:"id" bigquery:"id"`
}
func buildPipeline(s beam.Scope) {
rawDummyBodies := pubsubio.Read(s, "project", "topic", &pubsubio.ReadOptions{Subscription: "sub.ID"})
dummyBodies := beam.ParDo(s, func(ctx context.Context, data []byte) (DummyBody, error) {
var body DummyBody
if err := json.Unmarshal(data, &body); err != nil {
log.Error(ctx, err)
fmt.Println("Error")
return body, err
}
fmt.Println("No Error")
return body, nil
}, rawDummyBodies)
debug.Printf(s, …Run Code Online (Sandbox Code Playgroud) go google-bigquery google-cloud-pubsub google-cloud-dataflow
我使用Dataflow的项目编译得很好
mvn compile
Run Code Online (Sandbox Code Playgroud)
但是当我将项目导入eclipse时,eclipse无法构建项目并出现以下错误
The project was not built since its build path is incomplete. Cannot find the class file for com.google.common.reflect.TypeToken. Fix the build path then try building this project
以下答案包括对以下常见问题的回答.
我想在dafalow ParDo中使用Memcache?任何想法如何?我不能使用现有的memcahse lib,因为它们属于appengine而且不可序列化.罗希特
我目前正在尝试运行数据流(Apache Beam,Python SDK)任务,以将大于100GB的Tweet文件导入BigQuery,但正在 Error: Message: Too many sources provided: 15285. Limit is 10000.
该任务将使用tweet(JSON),提取5个相关字段,并通过一些转换对它们进行一些转换/消毒,然后将这些值写入BigQuery,以用于进一步处理。
BigQuery有Cloud Dataflow-来源过多,但这似乎是由于输入文件过多而引起的,而我只有一个输入文件,因此似乎无关紧要。另外,这里提到的解决方案是很神秘的,我不确定是否/如何将它们应用于我的问题。
我的猜测是,BigQuery在持久存储之前为每一行或其他内容写入临时文件,这就是“太多源”的含义吗?
我怎样才能解决这个问题?
[编辑]
码:
import argparse
import json
import logging
import apache_beam as beam
class JsonCoder(object):
"""A JSON coder interpreting each line as a JSON string."""
def encode(self, x):
return json.dumps(x)
def decode(self, x):
return json.loads(x)
def filter_by_nonempty_county(record):
if 'county_fips' in record and record['county_fips'] is not None:
yield record
def run(argv=None):
parser = argparse.ArgumentParser()
parser.add_argument('--input',
default='...',
help=('Input twitter json …Run Code Online (Sandbox Code Playgroud) 我有一个Apache Beam管道成功运行作为数据流模板.但是,我有一个选项类(扩展DataflowPipelineOptions).生成模板时,此类从pom或命令行界面获取参数.我想知道是否存在某个类,以便我可以直接从属性文件中加载这些参数.这样,从环境切换到环境会更容易,而且更干净
因此,我正在做一个小项目,该项目使用Google Dataflow和apache beam建立流传输管道。我完成了一些教程,能够建立流水线并在BigQuery中运行流,但是我想将其流到完整的关系数据库(即Cloud SQL)中。我已经在这个网站和整个google上进行了搜索,似乎最好的方法是使用JdbcIO。我在这里有点困惑,因为当我查找有关如何执行此操作的信息时,它们都是指批量写入云SQL而不是完全流式传输。
我的简单问题是,我可以将数据直接流到Cloud SQL中,还是必须通过批处理发送。
干杯!
我有一个从pubsub获得的Object的PCollection,可以这样说:
PCollection<Student> pStudent ;
Run Code Online (Sandbox Code Playgroud)
在学生属性中,有一个属性,比如说studentID;并且我想使用此学生ID从BigQuery读取属性(class_code),并将我从BQ获取的class_code设置为PCollcetion中的Student Object
有谁知道如何实现这一目标?我知道在Beam中有一个,BigQueryIO但是如果我要在BQ中执行的查询字符串条件来自PCollection中的学生对象(studentID),那么我该怎么办?如何从BigQuery的结果中将值设置为PCollection ?
我正在尝试构建将Pub / Sub流式传输到BigQuery的以下示例:
代码是:
/*
* Copyright (C) 2018 Google Inc.
*
* Licensed 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 …Run Code Online (Sandbox Code Playgroud) google-bigquery google-cloud-platform google-cloud-pubsub google-cloud-dataflow apache-beam