如何在数据融合中将模式文件作为宏传递给 BigQuery 接收器
How to pass schema file as Macros to BigQuery sink in data fusion
我正在创建一个数据融合管道,以针对我的用例将 csv 数据从 GCS 加载到 BigQuery 我需要创建一个 属性 宏并在运行时提供值。需要了解我们如何将架构文件作为宏传递给 BigQuery 接收器。
如果我只是将 json 架构文件路径传递给宏值,我会收到以下错误。
java.lang.IllegalArgumentException:无效模式:使用 JsonReader.setLenient(true) 接受第 1 行第 1 列
格式错误的 JSON
目前没有办法将文件的内容用作宏值,尽管有一个 jira 为这样的东西打开 (https://issues.cask.co/browse/CDAP-15424). It is expected that the schema contents should be set as macro value. The UI currently doesn't handle these types of macro values very well (https://issues.cask.co/browse/CDAP-15423), so I would suggest setting it through the REST endpoint (https://docs.cdap.io/cdap/6.0.0/en/reference-manual/http-restful-api/preferences.html#H2290),其中应用程序名称是管道名称。
或者,您可以通过编写如下所示的 Action 插件使您的管道更通用:
@Override
public void run(ActionContext context) throws Exception {
String schema = readFileContents();
context.getArguments().setArgument(key, schema);
}
该插件将是您管道中的第一个阶段,并允许您管道中的后续阶段使用 ${key} 作为将替换为实际架构的宏。
我正在创建一个数据融合管道,以针对我的用例将 csv 数据从 GCS 加载到 BigQuery 我需要创建一个 属性 宏并在运行时提供值。需要了解我们如何将架构文件作为宏传递给 BigQuery 接收器。 如果我只是将 json 架构文件路径传递给宏值,我会收到以下错误。
java.lang.IllegalArgumentException:无效模式:使用 JsonReader.setLenient(true) 接受第 1 行第 1 列
格式错误的 JSON目前没有办法将文件的内容用作宏值,尽管有一个 jira 为这样的东西打开 (https://issues.cask.co/browse/CDAP-15424). It is expected that the schema contents should be set as macro value. The UI currently doesn't handle these types of macro values very well (https://issues.cask.co/browse/CDAP-15423), so I would suggest setting it through the REST endpoint (https://docs.cdap.io/cdap/6.0.0/en/reference-manual/http-restful-api/preferences.html#H2290),其中应用程序名称是管道名称。
或者,您可以通过编写如下所示的 Action 插件使您的管道更通用:
@Override
public void run(ActionContext context) throws Exception {
String schema = readFileContents();
context.getArguments().setArgument(key, schema);
}
该插件将是您管道中的第一个阶段,并允许您管道中的后续阶段使用 ${key} 作为将替换为实际架构的宏。