MCPcopy Create free account
hub / github.com/datasweet/datatable / sampleForJoin

Function sampleForJoin

join_test.go:13–33  ·  view source on GitHub ↗

https://sql.sh/cours/jointures/inner-join

()

Source from the content-addressed store, hash-verified

11
12// https://sql.sh/cours/jointures/inner-join
13func sampleForJoin() (*datatable.DataTable, *datatable.DataTable) {
14 customers := datatable.New("Customers")
15 customers.AddColumn("id", datatable.Int)
16 customers.AddColumn("prenom", datatable.String)
17 customers.AddColumn("nom", datatable.String)
18 customers.AddColumn("email", datatable.String)
19 customers.AddColumn("ville", datatable.String)
20 // customers.AddColumn("concat", datatable.String, datatable.Expr("CONCAT(`prenom`,`nom`)"))
21 customers.AppendRow(1, "Aimée", "Marechal", "aime.marechal@example.com", "Paris")
22 customers.AppendRow(2, "Esmée", "Lefort", "esmee.lefort@example.com", "Lyon")
23 customers.AppendRow(3, "Marine", "Prevost", "m.prevost@example.com", "Lille")
24 customers.AppendRow(4, "Luc", "Rolland", "lucrolland@example.com", "Marseille")
25
26 orders := datatable.New("Orders")
27 orders.AddColumn("user_id", datatable.Int, datatable.Values(1, 1, 2, 3, 5))
28 orders.AddColumn("date_achat", datatable.Time, datatable.Values("2013-01-23", "2013-02-14", "2013-02-17", "2013-02-21", "2013-03-02"))
29 orders.AddColumn("num_facture", datatable.String, datatable.Values("A00103", "A00104", "A00105", "A00106", "A00107"))
30 orders.AddColumn("prix_total", datatable.Float64, datatable.Values(203.14, 124.00, 149.45, 235.35, 47.58))
31
32 return customers, orders
33}
34
35func TestJoinOn(t *testing.T) {
36 on := datatable.On("[customers].[id]")

Callers 11

TestWhereFunction · 0.85
TestAggregateFunction · 0.85
TestSortFunction · 0.85
TestInnerJoinFunction · 0.85
TestLeftJoinFunction · 0.85
TestRightJoinFunction · 0.85
TestOuterJoinFunction · 0.85
TestLeftJoinWithExprFunction · 0.85
TestRightJoinWithExprFunction · 0.85
TestJoinWithColumnNameFunction · 0.85

Calls 4

NewFunction · 0.92
ValuesFunction · 0.92
AddColumnMethod · 0.80
AppendRowMethod · 0.80

Tested by

no test coverage detected