我使用sparksql将11个表从一个数据库(db1)完全导出到另一个数据库(db2)。一旦导出完成,我就用表名比较db1和db2上每个表的计数,并检查它们是否匹配。输出列应该是,
Table_name DB1_count DB2_count Match (Y/N) ?
table_1 500 500 Y
table_2 376 325 N
到目前为止,我已经能够为一个表获取第2列和第3列。但是,我不知道如何对多个表以及列1和列4实现相同的功能。
1条答案
按热度按时间muk1a3rh1#
假设你有两张table:
和
可以添加“表名”列和“匹配”列,并执行联合:
要动态生成查询,可以尝试: