我有一个Dataframe列 table_name
具有以下字符串值:
tradingpartner.parent_supplier,lookup.store,lab_promo_invoice.tl_cc_mbr_prc_wkly_inv,lab_promo_invoice.mpp_club_card_promotion_funding_view,lab_promo_invoice.supplier_sale_apportionment_cc,tradingpartner.supplier,stores.rpm_zone_location_mapping,lookup.calendar
如何从上面的字符串中提取db name和table name并将其存储为 DB name
在一列和 tablename
在另一个专栏里。
我希望输出如下
1条答案
按热度按时间qc6wkl3g1#
一个可能的解决方案是定义两个不同的udf来实现这个目标。
从这个输入Dataframe开始,称为
dfInput
:第一个自定义项,称为
dbName
,负责从输入字符串列中获取字符串中的所有数据库名称:第二个自定义项,称为
tableName
,负责从输入字符串列中获取字符串中的所有表名:然后,为了获得预期的输出,我们需要如下调用UDF: