Union join
Returns a table with concatenated rows of left and right table. Columns are filled with none if needed.
Example
Include required headers and define the columns:
#include <cpptables/table.hh>
#include <iostream>
using namespace tables;
using namespace std;
struct c0{ constexpr static string_view name = "Col0"; };
struct c1{ constexpr static string_view name = "Col1"; };
struct c2{ constexpr static string_view name = "Col2"; };
Construct left table:
using table0_t = table<
pair<c0,string_view>,
pair<c1,int>
>;
const table0_t t0(
{"abc", "def", "ghi", "abc", "def", "ghi"},
{100,200,300,400,500,600}
);
cout << "t0:\n" << t0 << "\n";
Construct right table:
using table1_t = table<
pair<c0,string_view>,
pair<c2,unsigned>
>;
const table1_t t1(
{"abc", "def", "foo"},
{1,2,3}
);
cout << "t1:\n" << t1 << "\n";
Do a union join of t0
and t1
:
const auto t_uj = t0.uj( t1 );
cout << "t_uj:\n" << t_lj << "\n";
Output should be:
t0: Col0 Col1 --------- abc 100 def 200 ghi 300 abc 400 def 500 ghi 600 t1: Col0 Col2 --------- abc 1 def 2 foo 3 t_uj: Col0 Col1 Col2 -------------- abc 100 1 def 200 2 ghi 300 none abc 400 1 def 500 2 ghi 600 none