第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將側面輸入/額外輸入傳遞給 JdbcIO RowMapper Java

如何將側面輸入/額外輸入傳遞給 JdbcIO RowMapper Java

犯罪嫌疑人X 2023-08-09 17:16:34
我正在嘗試使用 JdbcIO.Read 讀取 Java Beam 中的云 SQL 表。我想使用 .withRowMapper(Resultset resultSet) 方法將 Resultset 中的每一行轉換為 GenericData.Record。有沒有辦法可以將 JSON 架構字符串作為 .withRowMapper 方法中的輸入傳遞,例如 ParDo 接受 sideInputs 作為 PCollectionView我嘗試過執(zhí)行這兩種讀取操作(在同一 JdbcIO.Read 轉換中從 information_schema.columns 和 My Table 讀取)。但是,我想先生成 Schema PCollection,然后使用 JdbcIO.Read 讀取表我正在動態(tài)生成表的 Avro 模式,如下所示:PCollection<String> avroSchema= pipeline.apply(JdbcIO.<String>read()                .withDataSourceConfiguration(config)                .withCoder(StringUtf8Coder.of())                .withQuery("SELECT DISTINCT column_name, data_type \n" +                        "FROM information_schema.columns\n" +                        "WHERE table_name = " + "'" + tableName + "'")                .withRowMapper((JdbcIO.RowMapper<String>) resultSet -> {            // code here to generate avro schema string           // this works fine for me}))創(chuàng)建 PCollectionView 它將保存每個表的 json 模式。 PCollectionView<String> s = avroSchema.apply(View.<String>asSingleton());// I want to access this view as side input in next JdbcIO.Read operation// something like this ;pipeline.apply(JdbcIO.<String>read()        .withDataSourceConfiguration(config)        .withCoder(StringUtf8Coder.of())        .withQuery(queryString)        .withRowMapper(new JdbcIO.RowMapper<String>() {            @Override            public String mapRow(ResultSet resultSet) throws Exception {                // access schema here and use it to parse and create                //GenericData.Record from ResultSet fields as per schema                return null;            }        })).    withSideInputs(My PCollectionView here); // this option is not there right now.有沒有更好的方法來解決這個問題?
查看完整描述

1 回答

?
千巷貓影

TA貢獻1829條經(jīng)驗 獲得超7個贊

此時 IO API 不接受 SideInputs。

在讀取后立即添加 ParDo 并在那里進行映射應該是可行的。ParDo 可以接受側面輸入。


查看完整回答
反對 回復 2023-08-09
  • 1 回答
  • 0 關注
  • 121 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號