From 8becfb11ea3c9635e2a59c11e0210c22f11b07cf Mon Sep 17 00:00:00 2001 From: henneberger Date: Thu, 12 Oct 2023 13:55:11 -0700 Subject: [PATCH] Update documentation syntax (#364) * Update documentation examples Signed-off-by: Daniel Henneberger * Snaps Signed-off-by: Daniel Henneberger --------- Signed-off-by: Daniel Henneberger --- README.md | 2 +- sqrl-examples/quickstart/quickstart-docs.sqrl | 4 ++-- sqrl-examples/quickstart/quickstart-export-err.sqrl | 4 ++-- sqrl-examples/quickstart/quickstart-export.sqrl | 4 ++-- sqrl-examples/quickstart/quickstart-mutation.sqrl | 4 ++-- sqrl-examples/quickstart/quickstart-sqrl.sqrl | 2 +- sqrl-examples/quickstart/quickstart-teaser-local.sqrl | 4 ++-- sqrl-examples/quickstart/quickstart-teaser.sqrl | 4 ++-- sqrl-examples/quickstart/quickstart-user.sqrl | 4 ++-- .../FlinkPhysicalUseCaseTest/quickstart-teaser-local.txt | 8 ++++---- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index fe14845b5..cf20fe8f4 100644 --- a/README.md +++ b/README.md @@ -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 */ diff --git a/sqrl-examples/quickstart/quickstart-docs.sqrl b/sqrl-examples/quickstart/quickstart-docs.sqrl index eead2b60a..be27433a9 100644 --- a/sqrl-examples/quickstart/quickstart-docs.sqrl +++ b/sqrl-examples/quickstart/quickstart-docs.sqrl @@ -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; diff --git a/sqrl-examples/quickstart/quickstart-export-err.sqrl b/sqrl-examples/quickstart/quickstart-export-err.sqrl index bd7003164..9e5bd2e2d 100644 --- a/sqrl-examples/quickstart/quickstart-export-err.sqrl +++ b/sqrl-examples/quickstart/quickstart-export-err.sqrl @@ -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, diff --git a/sqrl-examples/quickstart/quickstart-export.sqrl b/sqrl-examples/quickstart/quickstart-export.sqrl index 90fb0dd84..b4f1b6db3 100644 --- a/sqrl-examples/quickstart/quickstart-export.sqrl +++ b/sqrl-examples/quickstart/quickstart-export.sqrl @@ -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, diff --git a/sqrl-examples/quickstart/quickstart-mutation.sqrl b/sqrl-examples/quickstart/quickstart-mutation.sqrl index 0184d3219..fcf21942c 100644 --- a/sqrl-examples/quickstart/quickstart-mutation.sqrl +++ b/sqrl-examples/quickstart/quickstart-mutation.sqrl @@ -4,7 +4,7 @@ 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; @@ -12,7 +12,7 @@ Orders.totals := SELECT sum(total) as price, -- 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, diff --git a/sqrl-examples/quickstart/quickstart-sqrl.sqrl b/sqrl-examples/quickstart/quickstart-sqrl.sqrl index d3cb5b254..c62903eaf 100644 --- a/sqrl-examples/quickstart/quickstart-sqrl.sqrl +++ b/sqrl-examples/quickstart/quickstart-sqrl.sqrl @@ -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; diff --git a/sqrl-examples/quickstart/quickstart-teaser-local.sqrl b/sqrl-examples/quickstart/quickstart-teaser-local.sqrl index 469ac02e0..fe049aaa3 100644 --- a/sqrl-examples/quickstart/quickstart-teaser-local.sqrl +++ b/sqrl-examples/quickstart/quickstart-teaser-local.sqrl @@ -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 */ diff --git a/sqrl-examples/quickstart/quickstart-teaser.sqrl b/sqrl-examples/quickstart/quickstart-teaser.sqrl index 31ebdbffe..2e8c7f372 100644 --- a/sqrl-examples/quickstart/quickstart-teaser.sqrl +++ b/sqrl-examples/quickstart/quickstart-teaser.sqrl @@ -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; diff --git a/sqrl-examples/quickstart/quickstart-user.sqrl b/sqrl-examples/quickstart/quickstart-user.sqrl index 08bdd1fcc..e092329eb 100644 --- a/sqrl-examples/quickstart/quickstart-user.sqrl +++ b/sqrl-examples/quickstart/quickstart-user.sqrl @@ -3,7 +3,7 @@ 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; @@ -11,7 +11,7 @@ Orders.totals := SELECT sum(total) as price, -- 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, diff --git a/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/flink/FlinkPhysicalUseCaseTest/quickstart-teaser-local.txt b/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/flink/FlinkPhysicalUseCaseTest/quickstart-teaser-local.txt index 50a56cea3..dbb6d50e3 100644 --- a/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/flink/FlinkPhysicalUseCaseTest/quickstart-teaser-local.txt +++ b/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/flink/FlinkPhysicalUseCaseTest/quickstart-teaser-local.txt @@ -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 @@ -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