def diff(table_a:, table_b:, force: false, using: ['id'], exclude_columns: nil, no_a_b: false)
      table_diff = "diff_#{table_a}_#{table_b}"
      exclude_columns ||= []
      using = using.map(&:downcase)
      DBX.info("Creating diff table #{table_diff}")
      DBX.connection do |conn|
        conn.execute("DROP TABLE IF EXISTS #{table_diff}") if force
        conn.execute(<<-SQL)
        CREATE TABLE #{table_diff} AS
        SELECT
          #{using.join(', ')},
          #{select_columns(table_a, exclude_columns: using + exclude_columns, no_a_b: no_a_b)}
        FROM #{table_a} AS a
        FULL OUTER JOIN #{table_b} b USING (#{using.join(',')})
        WHERE
          #{where_columns(table_a, exclude_columns: using + exclude_columns)}
        SQL
        DBX.info(conn.exec_query(<<-SQL).as_json)
        SELECT
          (SELECT COUNT(*) FROM #{table_a}) count_table_a,
          (SELECT COUNT(*) FROM #{table_b}) count_table_b,
          (SELECT COUNT(*) FROM #{table_diff}) diffs
        SQL
      end
      DBX.info("Creating diff stats: #{table_diff}")
      create_diff_stats(table_diff, force: force)

      DBX.info("Diff complete. Results details in:   #{table_diff}")
    end
def diff(table_a:, table_b:, force: false, using: ['id'], exclude_columns: nil, no_a_b: false)
      table_diff = "diff_#{table_a}_#{table_b}"
      exclude_columns ||= []
      using = using.map(&:downcase)
      DBX.info("Creating diff table #{table_diff}")
      DBX.connection do |conn|
        conn.execute("DROP TABLE IF EXISTS #{table_diff}") if force
        conn.execute(<<-SQL)
        CREATE TABLE #{table_diff} AS
        SELECT
          #{using.join(', ')},
          #{select_columns(table_a, exclude_columns: using + exclude_columns, no_a_b: no_a_b)}
        FROM #{table_a} AS a
        FULL OUTER JOIN #{table_b} b USING (#{using.join(',')})
        WHERE
          #{where_columns(table_a, exclude_columns: using + exclude_columns)}
        SQL
        DBX.info(conn.exec_query(<<-SQL).as_json)
        SELECT
          (SELECT COUNT(*) FROM #{table_a}) count_table_a,
          (SELECT COUNT(*) FROM #{table_b}) count_table_b,
          (SELECT COUNT(*) FROM #{table_diff}) diffs
        SQL
      end
      DBX.info("Creating diff stats: #{table_diff}")
      create_diff_stats(table_diff, force: force)

      DBX.info("Diff complete. Results details in:   #{table_diff}")
    end
Compare `src_a` with `src_b`.
 Numeric types will be diffed by subtracting the values.
 Dates will contain difference by day.
 Datetime will contain difference by seconds.
 Everything else can only return a boolean true/false that it is different.

 @param [String] table A Should be the initial state table.
 @param [String] table B Should be newer than table A, but doesn't have to be.
 @param [Array<String>] using is the join criteria between the 2 tables.
 @param [Array<String>] exclude_columns are excluded from the diff comparison.