Skip to content

Commit

Permalink
fix: populating work/job database at appropriate times
Browse files Browse the repository at this point in the history
  • Loading branch information
gvwilson committed Feb 6, 2024
1 parent 2d09758 commit 0f3d316
Show file tree
Hide file tree
Showing 35 changed files with 125 additions and 162 deletions.
21 changes: 10 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ EXCLUDED_SQL := \
${SRC}/make_active.sql \
${SRC}/create_work_job.sql \
${SRC}/lineage_setup.sql \
${SRC}/trigger_setup.sql
${SRC}/populate_work_job.sql \
${SRC}/trigger_setup.sql \
${SRC}/update_work_job.sql
OUT_FILES := \
$(patsubst ${SRC}/%.sql,${OUT}/%.out,$(filter-out ${EXCLUDED_SQL},${SQL_FILES})) \
$(patsubst ${SRC}/%.py,${OUT}/%.out,${PY_FILES})
Expand Down Expand Up @@ -115,7 +117,7 @@ ${OUT}/autoincrement.out: ${SRC}/autoincrement.sql
${OUT}/avoid_correlated_subqueries.out: ${SRC}/avoid_correlated_subqueries.sql
cat ${MODE} $< | ${ASSAYS} > $@

${OUT}/backing_up.out: ${SRC}/backing_up.sql ${SRC}/create_work_job.sql
${OUT}/backing_up.out: ${SRC}/backing_up.sql ${SRC}/create_work_job.sql ${SRC}/populate_work_job.sql ${SRC}/update_work_job.sql
cat ${MODE} $< | ${MEMORY} > $@

${OUT}/basic_python_query.out: ${SRC}/basic_python_query.py
Expand Down Expand Up @@ -183,7 +185,7 @@ ${OUT}/date_sequence.out: ${SRC}/date_sequence.sql
${OUT}/dates_times.out: ${SRC}/dates_times.py
python $< > $@

${OUT}/delete_rows.out: ${SRC}/delete_rows.sql ${SRC}/create_work_job.sql
${OUT}/delete_rows.out: ${SRC}/delete_rows.sql ${SRC}/create_work_job.sql ${SRC}/populate_work_job.sql
cat ${MODE} $< | ${MEMORY} > $@

${OUT}/distinct.out: ${SRC}/distinct.sql
Expand Down Expand Up @@ -243,7 +245,7 @@ ${OUT}/insert_delete.out: ${SRC}/insert_delete.py
${OUT}/insert_select.out: ${SRC}/insert_select.sql
cat ${MODE} $< | ${MEMORY} > $@

${OUT}/insert_values.out: ${SRC}/insert_values.sql ${SRC}/create_work_job.sql
${OUT}/insert_values.out: ${SRC}/insert_values.sql ${SRC}/create_work_job.sql ${SRC}/populate_work_job.sql
cat ${MODE} $< | ${MEMORY} > $@

${OUT}/interpolate.out: ${SRC}/interpolate.py
Expand Down Expand Up @@ -318,13 +320,13 @@ ${OUT}/readable_aggregation.out: ${SRC}/readable_aggregation.sql
${OUT}/recursive_labeling.out: ${SRC}/recursive_labeling.sql
cat ${MODE} $< | ${CONTACTS} > $@

${OUT}/recursive_lineage.out: ${SRC}/recursive_lineage.sql
${OUT}/recursive_lineage.out: ${SRC}/recursive_lineage.sql ${SRC}/lineage_setup.sql
cat ${MODE} $< | ${MEMORY} > $@

${OUT}/rename_columns.out: ${SRC}/rename_columns.sql
cat ${MODE} $< | ${PENGUINS} > $@

${OUT}/represent_graph.out: ${SRC}/represent_graph.sql
${OUT}/represent_graph.out: ${SRC}/represent_graph.sql ${SRC}/lineage_setup.sql
cat ${MODE} $< | ${MEMORY} > $@

${OUT}/rollback_constraint.out: ${SRC}/rollback_constraint.sql
Expand Down Expand Up @@ -366,9 +368,6 @@ ${OUT}/set_membership.out: ${SRC}/set_membership.sql ${SRC}/create_work_job.sql
${OUT}/show_missing_values.out: ${SRC}/show_missing_values.sql
cat ${MODE} $< | ${PENGUINS} > $@

${OUT}/show_work_job.out: ${SRC}/show_work_job.sql ${SRC}/create_work_job.sql
cat ${MODE} $< | ${MEMORY} > $@

${OUT}/simple_group.out: ${SRC}/simple_group.sql
cat ${MODE} $< | ${PENGUINS} > $@

Expand Down Expand Up @@ -409,13 +408,13 @@ ${OUT}/update_group_ids.out: ${SRC}/update_group_ids.sql
cp ${DB}/contact_tracing.db /tmp
cat ${MODE} $< | ${CONTACTS_TMP} > $@

${OUT}/update_rows.out: ${SRC}/update_rows.sql ${SRC}/create_work_job.sql
${OUT}/update_rows.out: ${SRC}/update_rows.sql ${SRC}/create_work_job.sql ${SRC}/populate_work_job.sql ${SRC}/update_work_job.sql
cat ${MODE} $< | ${MEMORY} > $@

${OUT}/upsert.out: ${SRC}/upsert.sql
-cat ${MODE} $< | ${MEMORY} >& $@

${OUT}/views.out: ${SRC}/views.sql
${OUT}/views.out: ${SRC}/views.sql ${SRC}/make_active.sql
cp ${DB}/penguins.db /tmp
cat ${MODE} $< | ${PENGUINS_TMP} > $@

Expand Down
2 changes: 1 addition & 1 deletion _data/glossary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
en:
term: cross join
def: >
A join that creates the cross-product of rows from two tables.
A join that creates the cross-product of rows from two tables.
- key: cte
en:
Expand Down
7 changes: 4 additions & 3 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ home: true
{% include h2_numbered.md title="create tables" %}

{% include single.md file="src/create_work_job.sql" %}
{% include single.md file="out/show_work_job.out" %}

- <code>create table <em>name</em></code> followed by parenthesized list of columns
- Each column is a name, a data type, and optional extra information
Expand All @@ -447,14 +446,16 @@ home: true

{% include h2_numbered.md title="insert data" %}

{% include double.md stem="insert_values" suffix="sql out" %}
{% include single.md file="src/populate_work_job.sql" %}
{% include single.md file="out/insert_values.out" %}

</section>
<section markdown="1">

{% include h2_numbered.md title="update rows" %}

{% include double.md stem="update_rows" suffix="sql out" %}
{% include single.md file="src/update_work_job.sql" %}
{% include single.md file="out/update_rows.out" %}

- (Almost) always specify row(w) to update using `where`
- Would otherwise update all rows
Expand Down
12 changes: 4 additions & 8 deletions out/aggregate_join.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | pay |
|--------|-----|
| mik | 2.0 |
| po | 0.5 |
13 changes: 5 additions & 8 deletions out/aggregate_left_join.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | pay |
|--------|-----|
| mik | 2.0 |
| po | 0.5 |
| tay | |
11 changes: 3 additions & 8 deletions out/backing_up.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | job |
|--------|----------|
| tae | complain |
13 changes: 5 additions & 8 deletions out/coalesce.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | pay |
|--------|-----|
| mik | 2.0 |
| po | 0.5 |
| tay | 0.0 |
22 changes: 14 additions & 8 deletions out/cross_join.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | job | name | billable |
|--------|-----------|-----------|----------|
| mik | calibrate | calibrate | 1.5 |
| mik | calibrate | clean | 0.5 |
| mik | clean | calibrate | 1.5 |
| mik | clean | clean | 0.5 |
| mik | complain | calibrate | 1.5 |
| mik | complain | clean | 0.5 |
| po | clean | calibrate | 1.5 |
| po | clean | clean | 0.5 |
| po | complain | calibrate | 1.5 |
| po | complain | clean | 0.5 |
| tay | complain | calibrate | 1.5 |
| tay | complain | clean | 0.5 |
15 changes: 7 additions & 8 deletions out/delete_rows.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | job |
|--------|-----------|
| mik | calibrate |
| mik | clean |
| mik | complain |
| po | clean |
| po | complain |
13 changes: 5 additions & 8 deletions out/inner_join.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | job | name | billable |
|--------|-----------|-----------|----------|
| mik | calibrate | calibrate | 1.5 |
| mik | clean | clean | 0.5 |
| po | clean | clean | 0.5 |
8 changes: 0 additions & 8 deletions out/insert_values.out
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| name | billable |
|-----------|----------|
| calibrate | 1.5 |
Expand Down
16 changes: 8 additions & 8 deletions out/left_join.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | job | name | billable |
|--------|-----------|-----------|----------|
| mik | calibrate | calibrate | 1.5 |
| mik | clean | clean | 0.5 |
| mik | complain | | |
| po | clean | clean | 0.5 |
| po | complain | | |
| tay | complain | | |
13 changes: 5 additions & 8 deletions out/negate_incorrectly.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person |
|--------|
| mik |
| po |
| tay |
13 changes: 9 additions & 4 deletions out/random_numbers.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
| rand | selector | name |
|----------------------|----------|-------------|
| -6001451967753577798 | 7 | Riaan Dua |
| -5172626638304050554 | 4 | Vedika Rout |
| rand | selector | name |
|----------------------|----------|-----------------|
| 7176652035743196310 | 0 | Divit Dhaliwal |
| -2243654635505630380 | 2 | Indrans Sridhar |
| -6940074802089166303 | 5 | Pranay Khanna |
| 8882650891091088193 | 9 | Riaan Dua |
| -45079732302991538 | 5 | Vedika Rout |
| -8973877087806386134 | 2 | Abram Chokshi |
| 3360598450426870356 | 9 | Romil Kapoor |
12 changes: 4 additions & 8 deletions out/set_membership.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | job |
|--------|----------|
| po | clean |
| po | complain |
16 changes: 0 additions & 16 deletions out/show_work_job.out

This file was deleted.

12 changes: 4 additions & 8 deletions out/subquery_set.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person |
|--------|
| po |
| tay |
16 changes: 8 additions & 8 deletions out/update_rows.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CREATE TABLE job (
name text not null,
billable real not null
);
CREATE TABLE work (
person text not null,
job text not null
);
| person | job |
|--------|-----------|
| mik | calibrate |
| mik | clean |
| mik | complain |
| po | clean |
| po | complain |
| tae | complain |
1 change: 1 addition & 0 deletions src/aggregate_join.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.read src/create_work_job.sql
.read src/populate_work_job.sql

-- start
select
Expand Down
1 change: 1 addition & 0 deletions src/aggregate_left_join.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.read src/create_work_job.sql
.read src/populate_work_job.sql

-- start
select
Expand Down
2 changes: 2 additions & 0 deletions src/backing_up.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.read src/create_work_job.sql
.read src/populate_work_job.sql
.read src/update_work_job.sql

-- start
create table backup (
Expand Down
1 change: 1 addition & 0 deletions src/coalesce.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.read src/create_work_job.sql
.read src/populate_work_job.sql

-- start
select
Expand Down
3 changes: 0 additions & 3 deletions src/create_work_job.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-- start
create table job (
name text not null,
billable real not null
Expand All @@ -7,5 +6,3 @@ create table work (
person text not null,
job text not null
);
-- end
.schema
1 change: 1 addition & 0 deletions src/cross_join.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.read src/create_work_job.sql
.read src/populate_work_job.sql

-- start
select *
Expand Down
2 changes: 2 additions & 0 deletions src/delete_rows.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.read src/create_work_job.sql
.read src/populate_work_job.sql
.read src/update_work_job.sql

-- start
delete from work
Expand Down
1 change: 1 addition & 0 deletions src/inner_join.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.read src/create_work_job.sql
.read src/populate_work_job.sql

-- start
select *
Expand Down
Loading

0 comments on commit 0f3d316

Please sign in to comment.