Skip to content

Commit

Permalink
Update documentation syntax (#364)
Browse files Browse the repository at this point in the history
* Update documentation examples

Signed-off-by: Daniel Henneberger <git@danielhenneberger.com>

* Snaps

Signed-off-by: Daniel Henneberger <git@danielhenneberger.com>

---------

Signed-off-by: Daniel Henneberger <git@danielhenneberger.com>
  • Loading branch information
henneberger authored Oct 12, 2023
1 parent 5281478 commit 8becfb1
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DataSQRL is a compiler for building data services and APIs from streaming, stati
IMPORT datasqrl.seedshop.Orders; -- Import orders stream
IMPORT time.startOfMonth; -- Import time function
/* Augment orders with aggregate calculations */
Orders.items.total := quantity * unit_price - discount?0.0;
Orders.items.total := quantity * unit_price - coalesce(discount, 0.0);
Orders.totals := SELECT sum(total) as price,
sum(discount) as saving FROM @.items;
/* Create new table of unique customers */
Expand Down
4 changes: 2 additions & 2 deletions sqrl-examples/quickstart/quickstart-docs.sqrl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ IMPORT datasqrl.seedshop.Products;
IMPORT time.*;
IMPORT datasqrl.seedshop.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp;

Orders.items.discount0 := discount?0.0;
Orders.items.discount0 := coalesce(discount, 0.0);
Orders.items.total := quantity * unit_price - discount0;
Orders.totals := SELECT sum(total) as price,
sum(discount0) as saving FROM @.items;

-- Replacing users from import
Users := DISTINCT Users ON id ORDER BY timestamp DESC;
--Users.country := country?'none';
--Users.country := coalesce(country, 'none');
Users.purchases := JOIN Orders ON Orders.customerid = @.id;
Orders.user := JOIN Users ON @.customerid = Users.id;

Expand Down
4 changes: 2 additions & 2 deletions sqrl-examples/quickstart/quickstart-export-err.sqrl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ IMPORT datasqrl.seedshop.Products;
IMPORT time.*;
IMPORT datasqrl.seedshop.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp;

Orders.items.discount0 := discount?0.0;
Orders.items.discount0 := coalesce(discount, 0.0);
Orders.items.total := quantity * unit_price - discount0;
Orders.totals := SELECT sum(total) as price,
sum(discount0) as saving FROM @.items;

Users := DISTINCT Users ON id ORDER BY timestamp DESC;
Users.purchases := JOIN Orders ON Orders.customerid = @.id;
Users.country0 := country?'none';
Users.country0 := coalesce(country, 'none');
Orders.user := JOIN Users ON @.customerid = Users.id;

Users.spending := SELECT endOfWeek(p.timestamp) AS week,
Expand Down
4 changes: 2 additions & 2 deletions sqrl-examples/quickstart/quickstart-export.sqrl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ IMPORT datasqrl.seedshop.Products;
IMPORT time.*;
IMPORT mySourcePackage.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp;

Orders.items.discount0 := discount?0.0;
Orders.items.discount0 := coalesce(discount, 0.0);
Orders.items.total := quantity * unit_price - discount0;
Orders.totals := SELECT sum(total) as price,
sum(discount0) as saving FROM @.items;

Users := DISTINCT Users ON id ORDER BY timestamp DESC;
Users.purchases := JOIN Orders ON Orders.customerid = @.id;
Users.country0 := country?'none';
Users.country0 := coalesce(country, 'none');
Orders.user := JOIN Users ON @.customerid = Users.id;

Users.spending := SELECT endOfWeek(p.timestamp) AS week,
Expand Down
4 changes: 2 additions & 2 deletions sqrl-examples/quickstart/quickstart-mutation.sqrl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ IMPORT time.*;
IMPORT mySourcePackage.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp;
IMPORT seedshop.ProductVisit;

Orders.items.discount0 := discount?0.0;
Orders.items.discount0 := coalesce(discount, 0.0);
Orders.items.total := quantity * unit_price - discount0;
Orders.totals := SELECT sum(total) as price,
sum(discount0) as saving FROM @.items;

-- Replacing users from import
Users := DISTINCT Users ON id ORDER BY timestamp DESC;
Users.purchases := JOIN Orders ON Orders.customerid = @.id;
Users.country0 := country?'none';
Users.country0 := coalesce(country, 'none');
Orders.user := JOIN Users ON @.customerid = Users.id;

Users.spending := SELECT endOfWeek(p.timestamp) AS week,
Expand Down
2 changes: 1 addition & 1 deletion sqrl-examples/quickstart/quickstart-sqrl.sqrl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ IMPORT datasqrl.seedshop.Orders;
IMPORT datasqrl.seedshop.Products;
IMPORT time.endOfWeek;

Orders.items.discount0 := discount?0.0; -- Data cleaning
Orders.items.discount0 := coalesce(discount, 0.0); -- Data cleaning
Orders.items.total := quantity * unit_price - discount0;
Orders.totals := SELECT sum(total) as price,
sum(discount0) as saving FROM @.items;
Expand Down
4 changes: 2 additions & 2 deletions sqrl-examples/quickstart/quickstart-teaser-local.sqrl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
IMPORT mySourcePackage.Orders; -- Import orders stream
IMPORT time.endOfWeek; -- Import time function
/* Augment orders with total price */
Orders.items.total := quantity * unit_price - discount?0.0;
Orders.items.total := quantity * unit_price - coalesce(discount, 0.0);
Orders.totals := SELECT sum(total) as price,
sum(discount?0.0) as saving FROM @.items;
sum(coalesce(discount, 0.0)) as saving FROM @.items;
/* Create new table of unique customers */
Users := SELECT DISTINCT customerid AS id FROM Orders;
/* Create relationship between customers and orders */
Expand Down
4 changes: 2 additions & 2 deletions sqrl-examples/quickstart/quickstart-teaser.sqrl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
IMPORT datasqrl.seedshop.Orders;
IMPORT time.endOfWeek;

Orders.items.total := quantity * unit_price - discount?0.0;
Orders.items.total := quantity * unit_price - coalesce(discount, 0.0);
Orders.totals := SELECT sum(total) as price,
sum(discount?0.0) as saving FROM @.items;
sum(coalesce(discount, 0.0)) as saving FROM @.items;

Users := SELECT DISTINCT customerid AS id FROM Orders;

Expand Down
4 changes: 2 additions & 2 deletions sqrl-examples/quickstart/quickstart-user.sqrl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ IMPORT datasqrl.seedshop.Products;
IMPORT time.*;
IMPORT mySourcePackage.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp;

Orders.items.discount0 := discount?0.0;
Orders.items.discount0 := coalesce(discount, 0.0);
Orders.items.total := quantity * unit_price - discount0;
Orders.totals := SELECT sum(total) as price,
sum(discount0) as saving FROM @.items;

-- Replacing users from import
Users := DISTINCT Users ON id ORDER BY timestamp DESC;
Users.purchases := JOIN Orders ON Orders.customerid = @.id;
Users.country0 := country?'none';
Users.country0 := coalesce(country, 'none');
Orders.user := JOIN Users ON @.customerid = Users.id;

Users.spending := SELECT endOfWeek(p.timestamp) AS week,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ LogicalProject(__pk1$id=[$0], week=[$1], spend=[$2], saved=[$3]) hints[Timestamp
LogicalProject(id=[$3], _time=[$4])
LogicalTableScan(table=[[orders$1]], hints=[[[WatermarkHint inheritPath:[] options:[4]]]]) hints[WatermarkHint options:[4]]
LogicalProject(__pk1$_uuid=[$0], price=[$2], saving=[$3], _time=[$1])
LogicalAggregate(group=[{0, 4}], price=[SUM($1)], saving=[SUM($2)]) hints[TumbleAggregationHint options:[4, INSTANT, -1, 1, 0]]
LogicalProject(__pk1$_uuid=[$0], total=[-(*($8, $9), CASE(IS NOT NULL($10), CAST($10):DOUBLE NOT NULL, 0.0:DOUBLE))], $f2=[CASE(IS NOT NULL($10), CAST($10):DOUBLE NOT NULL, 0.0:DOUBLE)], _idx=[$6], time=[$4])
LogicalAggregate(group=[{0, 4}], price=[SUM($1)], agg#1=[SUM($2)]) hints[TumbleAggregationHint options:[4, INSTANT, -1, 1, 0]]
LogicalProject(__pk1$_uuid=[$0], total=[-(*($8, $9), COALESCE($10, 0.0:DOUBLE))], $f2=[COALESCE($10, 0.0:DECIMAL(2, 1))], _idx=[$6], time=[$4])
LogicalCorrelate(correlation=[$cor8], joinType=[inner], requiredColumns=[{5}])
LogicalTableScan(table=[[orders$1]], hints=[[[WatermarkHint inheritPath:[] options:[4]]]]) hints[WatermarkHint options:[4]]
Uncollect
Expand All @@ -23,8 +23,8 @@ LogicalProject(__pk1$id=[$0], week=[$1], spend=[$2], saved=[$3]) hints[Timestamp

>>>totals$1-lp-stream
LogicalProject(__pk1$_uuid=[$0], price=[$2], saving=[$3], _time=[$1]) hints[TimestampHint options:[3]]
LogicalAggregate(group=[{0, 4}], price=[SUM($1)], saving=[SUM($2)]) hints[TumbleAggregationHint options:[4, INSTANT, -1, 1, 0]]
LogicalProject(__pk1$_uuid=[$0], total=[-(*($8, $9), CASE(IS NOT NULL($10), CAST($10):DOUBLE NOT NULL, 0.0:DOUBLE))], $f2=[CASE(IS NOT NULL($10), CAST($10):DOUBLE NOT NULL, 0.0:DOUBLE)], _idx=[$6], time=[$4])
LogicalAggregate(group=[{0, 4}], price=[SUM($1)], agg#1=[SUM($2)]) hints[TumbleAggregationHint options:[4, INSTANT, -1, 1, 0]]
LogicalProject(__pk1$_uuid=[$0], total=[-(*($8, $9), COALESCE($10, 0.0:DOUBLE))], $f2=[COALESCE($10, 0.0:DECIMAL(2, 1))], _idx=[$6], time=[$4])
LogicalCorrelate(correlation=[$cor8], joinType=[inner], requiredColumns=[{5}])
LogicalTableScan(table=[[orders$1]], hints=[[[WatermarkHint inheritPath:[] options:[4]]]]) hints[WatermarkHint options:[4]]
Uncollect
Expand Down

0 comments on commit 8becfb1

Please sign in to comment.