diff --git a/sqrl-engines/sqrl-engine-jdbc/src/main/java/com/datasqrl/engine/database/relational/JDBCPhysicalPlan.java b/sqrl-engines/sqrl-engine-jdbc/src/main/java/com/datasqrl/engine/database/relational/JDBCPhysicalPlan.java index 8bc0ad8c3..fb78b8c31 100644 --- a/sqrl-engines/sqrl-engine-jdbc/src/main/java/com/datasqrl/engine/database/relational/JDBCPhysicalPlan.java +++ b/sqrl-engines/sqrl-engine-jdbc/src/main/java/com/datasqrl/engine/database/relational/JDBCPhysicalPlan.java @@ -3,26 +3,18 @@ */ package com.datasqrl.engine.database.relational; -import com.datasqrl.engine.PhysicalPlan.StagePlan; import com.datasqrl.engine.database.DatabasePhysicalPlan; import com.datasqrl.engine.database.QueryTemplate; -import com.datasqrl.engine.database.relational.ddl.JdbcDDLFactory; -import com.datasqrl.engine.database.relational.ddl.JdbcDDLServiceLoader; import com.datasqrl.engine.database.relational.ddl.SqlDDLStatement; -import com.datasqrl.io.impl.jdbc.JdbcDataSystemConnector; -import com.datasqrl.plan.global.IndexDefinition; -import com.datasqrl.plan.queries.APIQuery; import com.datasqrl.plan.queries.IdentifiedQuery; import com.datasqrl.serializer.Deserializer; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collection; -import java.util.stream.Collectors; -import lombok.Value; - import java.util.List; import java.util.Map; +import java.util.stream.Collectors; +import lombok.Value; @Value public class JDBCPhysicalPlan implements DatabasePhysicalPlan { diff --git a/sqrl-examples/mutations/script.sqrl b/sqrl-examples/mutations/script.sqrl index 0f251ab33..193a1deb4 100644 --- a/sqrl-examples/mutations/script.sqrl +++ b/sqrl-examples/mutations/script.sqrl @@ -1,3 +1,3 @@ IMPORT schema.createEvent AS event; IMPORT string.*; -event.name := RTRIM(LTRIM(name)); \ No newline at end of file +event.trimmed_name := RTRIM(LTRIM(name)); \ No newline at end of file diff --git a/sqrl-examples/nutshop/customer360-adv/customer360-adv.sqrl b/sqrl-examples/nutshop/customer360-adv/customer360-adv.sqrl index a811c91d4..fa53b4bcb 100644 --- a/sqrl-examples/nutshop/customer360-adv/customer360-adv.sqrl +++ b/sqrl-examples/nutshop/customer360-adv/customer360-adv.sqrl @@ -1,7 +1,7 @@ IMPORT nutshop-small.Products; IMPORT nutshop-small.Orders TIMESTAMP epoch_to_timestamp(time/1000) AS timestamp; -Orders.items.discount := coalesce(discount, 0.0); +Orders.items.discount0 := coalesce(discount, 0.0); Customers := SELECT DISTINCT customerid AS id FROM Orders; Products := DISTINCT Products ON id ORDER BY updated DESC; @@ -9,8 +9,8 @@ Products := DISTINCT Products ON id ORDER BY updated DESC; Customers.purchases := JOIN Orders ON Orders.customerid = @.id ORDER BY Orders.time DESC; Orders.items.product := JOIN Products ON Products.id = @.productid; -Orders.items.total := quantity * unit_price - discount; -Orders.totals := SELECT sum(total) as price, sum(discount) as savings FROM @.items; +Orders.items.total := quantity * unit_price - discount0; +Orders.totals := SELECT sum(total) as price, sum(discount0) as savings FROM @.items; Customers.spending_by_month := SELECT endOfmonth(p.timestamp) AS month, diff --git a/sqrl-examples/nutshop/customer360-api/customer360-api.sqrl b/sqrl-examples/nutshop/customer360-api/customer360-api.sqrl index fa3471727..df2ce5db3 100644 --- a/sqrl-examples/nutshop/customer360-api/customer360-api.sqrl +++ b/sqrl-examples/nutshop/customer360-api/customer360-api.sqrl @@ -6,7 +6,7 @@ IMPORT usda-data.nuts; Products := DISTINCT Products ON id ORDER BY _ingest_time DESC; Orders.date := EPOCH_TO_TIMESTAMP(time); -Orders.items.discount := coalesce(discount, 0.0); +Orders.items.discount0 := coalesce(discount, 0.0); -- @api(name="User", query="getusers") Customers := SELECT DISTINCT customerid AS id FROM Orders; @@ -14,14 +14,14 @@ Customers := SELECT DISTINCT customerid AS id FROM Orders; Customers.purchases := JOIN Orders ON Orders.customerid = @.id ORDER BY Orders.time DESC; Orders.items.product := JOIN Products ON Products.id = @.productid LIMIT 1; -Orders.items.total := quantity * unit_price - discount; +Orders.items.total := quantity * unit_price - discount0; Orders.total := sum(items.total); -Orders.savings := sum(items.discount); +Orders.savings := sum(items.discount0); Customers.spending_by_month := SELECT TRUNCATE_TO_MONTH(date) AS month, sum(total) AS total_spend, - sum(discount) AS total_savings + sum(discount0) AS total_savings FROM @.purchases GROUP BY month ORDER BY month DESC; diff --git a/sqrl-examples/nutshop/customer360-ext/customer360-ext.sqrl b/sqrl-examples/nutshop/customer360-ext/customer360-ext.sqrl index d637555f2..fbf3330ad 100644 --- a/sqrl-examples/nutshop/customer360-ext/customer360-ext.sqrl +++ b/sqrl-examples/nutshop/customer360-ext/customer360-ext.sqrl @@ -5,21 +5,21 @@ IMPORT usda-data.nuts; Products := DISTINCT Products ON id ORDER BY _ingest_time DESC; Orders.date := EPOCH_TO_TIMESTAMP(time); -Orders.items.discount := coalesce(discount, 0.0); +Orders.items.discount0 := coalesce(discount, 0.0); Customers := SELECT DISTINCT customerid AS id FROM Orders; Customers.purchases := JOIN Orders ON Orders.customerid = @.id ORDER BY Orders.time DESC; Orders.items.product := JOIN Products ON Products.id = @.productid LIMIT 1; -Orders.items.total := quantity * unit_price - discount; +Orders.items.total := quantity * unit_price - discount0; Orders.total := sum(items.total); -Orders.savings := sum(items.discount); +Orders.savings := sum(items.discount0); Customers.spending_by_month := SELECT TRUNCATE_TO_MONTH(date) AS month, sum(total) AS total_spend, - sum(discount) AS total_savings + sum(discount0) AS total_savings FROM @.purchases GROUP BY month ORDER BY month DESC; diff --git a/sqrl-examples/nutshop/customer360/nutshopv1-small.sqrl b/sqrl-examples/nutshop/customer360/nutshopv1-small.sqrl index b45526686..6ce788e05 100644 --- a/sqrl-examples/nutshop/customer360/nutshopv1-small.sqrl +++ b/sqrl-examples/nutshop/customer360/nutshopv1-small.sqrl @@ -5,7 +5,7 @@ IMPORT nutshop-small.Products; IMPORT nutshop-small.Orders TIMESTAMP epochToTimestamp(time/1000) AS timestamp; /* Some order items are missing the discount field - let's clean that up */ -Orders.items.discount := coalesce(discount, 0.0); +Orders.items.discount0 := coalesce(discount, 0.0); /* The Customers table are all the `customerid` that have placed an order */ Customers := SELECT DISTINCT customerid AS id FROM Orders; @@ -19,9 +19,9 @@ Customers.purchases := JOIN Orders ON Orders.customerid = @.id ORDER BY Orders.t Orders.items.product := JOIN Products ON Products.id = @.productid; /* Add a column to compute the total for each item in an order */ -Orders.items.total := quantity * unit_price - discount; +Orders.items.total := quantity * unit_price - discount0; /* Adds a nested table `totals` in Orders to compute the totals for each Order */ -Orders.totals := SELECT sum(total) as price, sum(discount) as savings FROM @.items; +Orders.totals := SELECT sum(total) as price, sum(discount0) as savings FROM @.items; /* Aggregates the purchase history for each customer by month */ Customers.spending_by_month := diff --git a/sqrl-examples/nutshop/customer360/nutshopv2-medium.sqrl b/sqrl-examples/nutshop/customer360/nutshopv2-medium.sqrl index 35f228190..e0c48d286 100644 --- a/sqrl-examples/nutshop/customer360/nutshopv2-medium.sqrl +++ b/sqrl-examples/nutshop/customer360/nutshopv2-medium.sqrl @@ -2,9 +2,9 @@ IMPORT time.*; IMPORT nutshop-medium.Products; IMPORT nutshop-medium.Orders TIMESTAMP epochToTimestamp(time/1000) AS timestamp; -Orders.items.discount := coalesce(discount, 0.0); -Orders.items.total := quantity * unit_price - discount; -Orders.totals := SELECT sum(total) as price, sum(discount) as savings FROM @.items; +Orders.items.discount0 := coalesce(discount, 0.0); +Orders.items.total := quantity * unit_price - discount0; +Orders.totals := SELECT sum(total) as price, sum(discount0) as savings FROM @.items; Products := DISTINCT Products ON id ORDER BY updated DESC; Orders.items.product := JOIN Products ON Products.id = @.productid; diff --git a/sqrl-examples/nutshop/customer360/nutshopv2-small.sqrl b/sqrl-examples/nutshop/customer360/nutshopv2-small.sqrl index d47b376ac..d30f02149 100644 --- a/sqrl-examples/nutshop/customer360/nutshopv2-small.sqrl +++ b/sqrl-examples/nutshop/customer360/nutshopv2-small.sqrl @@ -2,9 +2,9 @@ IMPORT time.*; IMPORT nutshop-compress.Products; IMPORT nutshop-compress.Orders TIMESTAMP epochToTimestamp(time/1000) AS timestamp; -Orders.items.discount := coalesce(discount, 0.0); -Orders.items.total := quantity * unit_price - discount; -Orders.totals := SELECT sum(total) as price, sum(discount) as savings FROM @.items; +Orders.items.discount0 := coalesce(discount, 0.0); +Orders.items.total := quantity * unit_price - discount0; +Orders.totals := SELECT sum(total) as price, sum(discount0) as savings FROM @.items; Products := DISTINCT Products ON id ORDER BY updated DESC; Orders.items.product := JOIN Products ON Products.id = @.productid; diff --git a/sqrl-examples/nutshop/customer360/nutshopv3-small.sqrl b/sqrl-examples/nutshop/customer360/nutshopv3-small.sqrl index 2e2643eb0..5d5d5a905 100644 --- a/sqrl-examples/nutshop/customer360/nutshopv3-small.sqrl +++ b/sqrl-examples/nutshop/customer360/nutshopv3-small.sqrl @@ -2,9 +2,9 @@ IMPORT time.*; IMPORT nutshop-small.Products; IMPORT nutshop-small.Orders TIMESTAMP epochToTimestamp(time/1000) AS timestamp; -Orders.items.discount := coalesce(discount, 0.0); -Orders.items.total := quantity * unit_price - discount; -Orders.totals := SELECT sum(total) as price, sum(discount) as savings FROM @.items; +Orders.items.discount0 := coalesce(discount, 0.0); +Orders.items.total := quantity * unit_price - discount0; +Orders.totals := SELECT sum(total) as price, sum(discount0) as savings FROM @.items; Products := DISTINCT Products ON id ORDER BY updated DESC; Orders.items.product := JOIN Products ON Products.id = @.productid; diff --git a/sqrl-examples/nutshop/customer360/v2graphql/nutshopv2-small.sqrl b/sqrl-examples/nutshop/customer360/v2graphql/nutshopv2-small.sqrl index d47b376ac..d30f02149 100644 --- a/sqrl-examples/nutshop/customer360/v2graphql/nutshopv2-small.sqrl +++ b/sqrl-examples/nutshop/customer360/v2graphql/nutshopv2-small.sqrl @@ -2,9 +2,9 @@ IMPORT time.*; IMPORT nutshop-compress.Products; IMPORT nutshop-compress.Orders TIMESTAMP epochToTimestamp(time/1000) AS timestamp; -Orders.items.discount := coalesce(discount, 0.0); -Orders.items.total := quantity * unit_price - discount; -Orders.totals := SELECT sum(total) as price, sum(discount) as savings FROM @.items; +Orders.items.discount0 := coalesce(discount, 0.0); +Orders.items.total := quantity * unit_price - discount0; +Orders.totals := SELECT sum(total) as price, sum(discount0) as savings FROM @.items; Products := DISTINCT Products ON id ORDER BY updated DESC; Orders.items.product := JOIN Products ON Products.id = @.productid; diff --git a/sqrl-examples/quickstart/quickstart-docs.sqrl b/sqrl-examples/quickstart/quickstart-docs.sqrl index 57f3bae44..eead2b60a 100644 --- a/sqrl-examples/quickstart/quickstart-docs.sqrl +++ b/sqrl-examples/quickstart/quickstart-docs.sqrl @@ -3,10 +3,10 @@ IMPORT datasqrl.seedshop.Products; IMPORT time.*; IMPORT datasqrl.seedshop.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp; -Orders.items.discount := discount?0.0; -Orders.items.total := quantity * unit_price - discount; +Orders.items.discount0 := discount?0.0; +Orders.items.total := quantity * unit_price - discount0; Orders.totals := SELECT sum(total) as price, - sum(discount) as saving FROM @.items; + sum(discount0) as saving FROM @.items; -- Replacing users from import Users := DISTINCT Users ON id ORDER BY timestamp DESC; @@ -52,12 +52,12 @@ UsersWithSpending := SELECT u.id, u.email, s.spend AS spend FROM Users u JOIN u. HighSpendingUsers := SELECT u.id, u.email FROM Users u JOIN u.order_stats s WHERE s.spend > 1000; Users.spending_last_week := SELECT sum(i.total) AS spend, - sum(i.discount) AS saved + sum(i.discount0) AS saved FROM @.purchases p JOIN p.items i WHERE p.time > now() - INTERVAL 7 DAY; Users.total_spend := SELECT sum(i.total) AS spend, - sum(i.discount) AS saved + sum(i.discount0) AS saved FROM @ JOIN Orders o ON o.customerid = @.id JOIN o.items i; RecentTotal := SELECT sum(i.total) AS total, sum(i.quantity) AS quantity diff --git a/sqrl-examples/quickstart/quickstart-export-err.sqrl b/sqrl-examples/quickstart/quickstart-export-err.sqrl index a00a6432e..bd7003164 100644 --- a/sqrl-examples/quickstart/quickstart-export-err.sqrl +++ b/sqrl-examples/quickstart/quickstart-export-err.sqrl @@ -1,19 +1,19 @@ -IMPORT datasqrl.seedshop.Orders TIMESTAMP time + INTERVAL 8 DAY AS time; +IMPORT datasqrl.seedshop.Orders TIMESTAMP time + INTERVAL 8 DAY AS timestamp; IMPORT datasqrl.seedshop.Products; IMPORT time.*; IMPORT datasqrl.seedshop.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp; -Orders.items.discount := discount?0.0; -Orders.items.total := quantity * unit_price - discount; +Orders.items.discount0 := discount?0.0; +Orders.items.total := quantity * unit_price - discount0; Orders.totals := SELECT sum(total) as price, - sum(discount) as saving FROM @.items; + sum(discount0) as saving FROM @.items; Users := DISTINCT Users ON id ORDER BY timestamp DESC; Users.purchases := JOIN Orders ON Orders.customerid = @.id; -Users.country := country?'none'; +Users.country0 := country?'none'; Orders.user := JOIN Users ON @.customerid = Users.id; -Users.spending := SELECT endOfWeek(p.time) AS week, +Users.spending := SELECT endOfWeek(p.timestamp) AS week, sum(t.price) AS spend, sum(t.saving) AS saved FROM @.purchases p JOIN p.totals t GROUP BY week ORDER BY week DESC; @@ -33,10 +33,10 @@ Products.ordered_items := JOIN Orders.items i ON i.productid = @.id; Products.volume_10day := SELECT u.country, sum(i.quantity) as quantity, sum(i.total) as spend, sum(i.quantity * @.weight_in_gram) as weight FROM @ JOIN @.ordered_items i JOIN i.parent o JOIN o.user u - WHERE o.time > now() - INTERVAL 10 DAY GROUP BY u.country; + WHERE o.timestamp > now() - INTERVAL 10 DAY GROUP BY u.country; -- -Users.order_stats := SELECT min(o.time) as first_order, +Users.order_stats := SELECT min(o.timestamp) as first_order, sum(t.price) as spend, sum(t.saving) as saved, count(1) as num_orders FROM @.purchases o JOIN o.totals t; diff --git a/sqrl-examples/quickstart/quickstart-export.sqrl b/sqrl-examples/quickstart/quickstart-export.sqrl index 4bac43f25..90fb0dd84 100644 --- a/sqrl-examples/quickstart/quickstart-export.sqrl +++ b/sqrl-examples/quickstart/quickstart-export.sqrl @@ -1,19 +1,19 @@ -IMPORT datasqrl.seedshop.Orders TIMESTAMP time + INTERVAL 8 DAY AS time; +IMPORT datasqrl.seedshop.Orders TIMESTAMP time + INTERVAL 8 DAY AS timestamp; IMPORT datasqrl.seedshop.Products; IMPORT time.*; IMPORT mySourcePackage.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp; -Orders.items.discount := discount?0.0; -Orders.items.total := quantity * unit_price - discount; +Orders.items.discount0 := discount?0.0; +Orders.items.total := quantity * unit_price - discount0; Orders.totals := SELECT sum(total) as price, - sum(discount) as saving FROM @.items; + sum(discount0) as saving FROM @.items; Users := DISTINCT Users ON id ORDER BY timestamp DESC; Users.purchases := JOIN Orders ON Orders.customerid = @.id; -Users.country := country?'none'; +Users.country0 := country?'none'; Orders.user := JOIN Users ON @.customerid = Users.id; -Users.spending := SELECT endOfWeek(p.time) AS week, +Users.spending := SELECT endOfWeek(p.timestamp) AS week, sum(t.price) AS spend, sum(t.saving) AS saved FROM @.purchases p JOIN p.totals t GROUP BY week ORDER BY week DESC; @@ -30,10 +30,10 @@ Products := DISTINCT Products ON id ORDER BY updated DESC; Orders.items.product := JOIN Products ON Products.id = @.productid; Products.ordered_items := JOIN Orders.items i ON i.productid = @.id; -Products.volume_10day := SELECT u.country, sum(i.quantity) as quantity, +Products.volume_10day := SELECT u.country0 AS country, sum(i.quantity) as quantity, sum(i.total) as spend, sum(i.quantity * @.weight_in_gram) as weight FROM @ JOIN @.ordered_items i JOIN i.parent o JOIN o.user u - WHERE o.time > now() - INTERVAL 10 DAY GROUP BY u.country; + WHERE o.timestamp > now() - INTERVAL 10 DAY GROUP BY u.country0; -- Users.order_stats := SELECT sum(t.price) as spend, sum(t.saving) as saved, diff --git a/sqrl-examples/quickstart/quickstart-mutation.sqrl b/sqrl-examples/quickstart/quickstart-mutation.sqrl index f6094450f..0184d3219 100644 --- a/sqrl-examples/quickstart/quickstart-mutation.sqrl +++ b/sqrl-examples/quickstart/quickstart-mutation.sqrl @@ -1,21 +1,21 @@ -IMPORT datasqrl.seedshop.Orders TIMESTAMP time + INTERVAL 8 DAY AS time; +IMPORT datasqrl.seedshop.Orders TIMESTAMP time + INTERVAL 8 DAY AS timestamp; IMPORT datasqrl.seedshop.Products; IMPORT time.*; IMPORT mySourcePackage.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp; IMPORT seedshop.ProductVisit; -Orders.items.discount := discount?0.0; -Orders.items.total := quantity * unit_price - discount; +Orders.items.discount0 := discount?0.0; +Orders.items.total := quantity * unit_price - discount0; Orders.totals := SELECT sum(total) as price, - sum(discount) as saving FROM @.items; + 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.country := country?'none'; +Users.country0 := country?'none'; Orders.user := JOIN Users ON @.customerid = Users.id; -Users.spending := SELECT endOfWeek(p.time) AS week, +Users.spending := SELECT endOfWeek(p.timestamp) AS week, sum(t.price) AS spend, sum(t.saving) AS saved FROM @.purchases p JOIN p.totals t GROUP BY week ORDER BY week DESC; @@ -38,7 +38,7 @@ Orders.items.product := JOIN Products ON Products.id = @.productid; Products.ordered_items := JOIN Orders.items i ON i.productid = @.id; -- aggregating by country -Products.volume_10day := SELECT u.country, sum(i.quantity) as quantity, +Products.volume_10day := SELECT u.country0 AS country, sum(i.quantity) as quantity, sum(i.total) as spend, sum(i.quantity * @.weight_in_gram) as weight FROM @ JOIN @.ordered_items i JOIN i.parent o JOIN o.user u - WHERE o.time > now() - INTERVAL 10 DAY GROUP BY u.country; \ No newline at end of file + WHERE o.timestamp > now() - INTERVAL 10 DAY GROUP BY u.country0; \ No newline at end of file diff --git a/sqrl-examples/quickstart/quickstart-sqrl.sqrl b/sqrl-examples/quickstart/quickstart-sqrl.sqrl index 834a30459..d3cb5b254 100644 --- a/sqrl-examples/quickstart/quickstart-sqrl.sqrl +++ b/sqrl-examples/quickstart/quickstart-sqrl.sqrl @@ -2,10 +2,10 @@ IMPORT datasqrl.seedshop.Orders; IMPORT datasqrl.seedshop.Products; IMPORT time.endOfWeek; -Orders.items.discount := discount?0.0; -- Data cleaning -Orders.items.total := quantity * unit_price - discount; +Orders.items.discount0 := discount?0.0; -- Data cleaning +Orders.items.total := quantity * unit_price - discount0; Orders.totals := SELECT sum(total) as price, - sum(discount) as saving FROM @.items; + sum(discount0) as saving FROM @.items; Users := SELECT DISTINCT customerid AS id FROM Orders; Users.purchases := JOIN Orders ON Orders.customerid = @.id ORDER BY Orders.time; -- time ordering diff --git a/sqrl-examples/quickstart/quickstart-user.sqrl b/sqrl-examples/quickstart/quickstart-user.sqrl index 07e23ba18..08bdd1fcc 100644 --- a/sqrl-examples/quickstart/quickstart-user.sqrl +++ b/sqrl-examples/quickstart/quickstart-user.sqrl @@ -1,20 +1,20 @@ -IMPORT datasqrl.seedshop.Orders TIMESTAMP time + INTERVAL 8 DAY AS time; +IMPORT datasqrl.seedshop.Orders TIMESTAMP time + INTERVAL 8 DAY AS timestamp; IMPORT datasqrl.seedshop.Products; IMPORT time.*; IMPORT mySourcePackage.Customers AS Users TIMESTAMP epochMilliToTimestamp(changed_on) AS timestamp; -Orders.items.discount := discount?0.0; -Orders.items.total := quantity * unit_price - discount; +Orders.items.discount0 := discount?0.0; +Orders.items.total := quantity * unit_price - discount0; Orders.totals := SELECT sum(total) as price, - sum(discount) as saving FROM @.items; + 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.country := country?'none'; +Users.country0 := country?'none'; Orders.user := JOIN Users ON @.customerid = Users.id; -Users.spending := SELECT endOfWeek(p.time) AS week, +Users.spending := SELECT endOfWeek(p.timestamp) AS week, sum(t.price) AS spend, sum(t.saving) AS saved FROM @.purchases p JOIN p.totals t GROUP BY week ORDER BY week DESC; @@ -34,7 +34,7 @@ Products.ordered_items := JOIN Orders.items i ON i.productid = @.id; -- -- aggregating by country -Products.volume_10day := SELECT u.country, sum(i.quantity) as quantity, +Products.volume_10day := SELECT u.country0 AS country, sum(i.quantity) as quantity, sum(i.total) as spend, sum(i.quantity * @.weight_in_gram) as weight FROM @ JOIN @.ordered_items i JOIN i.parent o JOIN o.user u - WHERE o.time > now() - INTERVAL 10 DAY GROUP BY u.country; \ No newline at end of file + WHERE o.timestamp > now() - INTERVAL 10 DAY GROUP BY u.country0; \ No newline at end of file diff --git a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/CatalogReader.java b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/CatalogReader.java index 3ba9c0b42..161354768 100644 --- a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/CatalogReader.java +++ b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/CatalogReader.java @@ -10,6 +10,7 @@ import org.apache.calcite.prepare.CalciteCatalogReader; import org.apache.calcite.rel.type.RelDataTypeFactory; import org.apache.calcite.sql.validate.SqlNameMatcher; +import org.apache.calcite.sql.validate.SqlNameMatchers; import org.apache.flink.calcite.shaded.com.google.common.collect.ImmutableList; public class CatalogReader extends CalciteCatalogReader { @@ -17,9 +18,8 @@ public class CatalogReader extends CalciteCatalogReader { @Getter private final SqrlSchema schema; - public CatalogReader(SqrlSchema rootSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config, - SqlNameMatcher nameMatcher) { - super(rootSchema, nameMatcher, ImmutableList.of(List.of(), ImmutableList.of()), typeFactory, config); + public CatalogReader(SqrlSchema rootSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) { + super(rootSchema, SqlNameMatchers.withCaseSensitive(false), ImmutableList.of(List.of(), ImmutableList.of()), typeFactory, config); this.schema = rootSchema; } diff --git a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/QueryPlanner.java b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/QueryPlanner.java index f639bfbc3..0e054e871 100644 --- a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/QueryPlanner.java +++ b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/QueryPlanner.java @@ -71,7 +71,8 @@ @Getter public class QueryPlanner { - private static final AtomicInteger uniqueCompilerId = new AtomicInteger(0); + private final AtomicInteger uniqueCompilerId = new AtomicInteger(0); + private final AtomicInteger uniquePkId = new AtomicInteger(0); private final RelOptCluster cluster; private final RelOptPlanner planner; private final CatalogReader catalogReader; diff --git a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/SqrlFramework.java b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/SqrlFramework.java index 4b34c4bdb..ef8bd702a 100644 --- a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/SqrlFramework.java +++ b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/SqrlFramework.java @@ -49,9 +49,7 @@ public SqrlFramework(RelMetadataProvider relMetadataProvider, HintStrategyTable CalciteConnectionConfigImpl config = new CalciteConnectionConfigImpl(info); this.nameCanonicalizer = nameCanonicalizer; - SqrlNameMatcher nameMatcher = new SqrlNameMatcher(nameCanonicalizer); - this.catalogReader = new CatalogReader(schema, typeFactory, config, - nameMatcher); + this.catalogReader = new CatalogReader(schema, typeFactory, config); this.sqrlOperatorTable = new OperatorTable(nameCanonicalizer, catalogReader, SqlStdOperatorTable.instance()); this.queryPlanner = resetPlanner(); } diff --git a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/SqrlNameMatcher.java b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/SqrlNameMatcher.java index 0586e6199..a203fbd04 100644 --- a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/SqrlNameMatcher.java +++ b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/SqrlNameMatcher.java @@ -18,78 +18,14 @@ import org.apache.calcite.sql.validate.SqlNameMatchers; /** - * Allows for choosing the most recent canonicalize column in a table. - * e.g. NAME -> name$1 + * Allows for choosing the most recent table function. */ @AllArgsConstructor -public class SqrlNameMatcher implements SqlNameMatcher { +public class SqrlNameMatcher { NameCanonicalizer canonicalizer; final SqlNameMatcher delegate = SqlNameMatchers.withCaseSensitive(false); - @Override - public boolean isCaseSensitive() { - return false; - } - - @Override - public boolean matches(String s, String s1) { - return delegate.matches(s, s1); - } - - @Override - public , V> V get(Map map, List list, List list1) { - return delegate.get(map, list, list1); - } - - @Override - public String bestString() { - return delegate.bestString(); - } - - @Override - public RelDataTypeField field(RelDataType relDataType, String s) { - RelDataTypeField f = relDataType.getField(s, false, false); - if (f != null) { - return f; - } - - String name = getLatestVersion(canonicalizer, relDataType.getFieldNames(), s); - if (name == null) { - return null; - } - int i = indexOf(relDataType.getFieldNames(), name); - return relDataType.getFieldList().get(i); - } - - @Override - public int indexOf(Iterable names, String name) { - List n = new ArrayList<>(); - names.iterator().forEachRemaining(n::add); - - List names1 = n.stream().map(na->canonicalizer.name(na)) - .collect(Collectors.toList()); - - if (names1.contains(canonicalizer.name(name))) { - return n.indexOf(name); - } - - String versioned = getLatestVersion(canonicalizer, n, name); - - return n.indexOf(versioned); - } - - @Override - public int frequency(Iterable iterable, String s) { - return delegate.frequency(iterable, s); - } - - @Override - public Set createSet() { - return delegate.createSet(); - } - - public static String getLatestVersion(NameCanonicalizer canonicalizer, Collection functionNames, String prefix) { //todo: use name comparator Set functionNamesCanon = functionNames.stream() diff --git a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/schema/ScriptPlanner.java b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/schema/ScriptPlanner.java index d7cf1701f..519e2b780 100644 --- a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/schema/ScriptPlanner.java +++ b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/calcite/schema/ScriptPlanner.java @@ -102,8 +102,8 @@ public static ResolvedExport exportTable(SQRLTable table, TableSink sink, RelBui List selects = new ArrayList<>(); List fieldNames = new ArrayList<>(); table.getVisibleColumns().stream().forEach(c -> { - selects.add(relBuilder.field(c.getId().getCanonical())); - fieldNames.add(subscription ? c.getId().getCanonical() : c.getName().getDisplay()); + selects.add(relBuilder.field(c.getId().getDisplay())); + fieldNames.add(subscription ? c.getId().getDisplay() : c.getName().getDisplay()); }); relBuilder.project(selects, fieldNames); return new ResolvedExport(table1.getNameId(), relBuilder.build(), sink); @@ -288,15 +288,14 @@ private int addColumn(RexNode node, String cName, RelOptTable table) { ModifiableTable table1 = (ModifiableTable) table.unwrap(Table.class); SQRLTable sqrlTable = table1.getSqrlTable(); Column column = sqrlTable.addColumn(nameUtil.toName(cName), null, true, node.getType()); - column.setVtName(column.getId().getCanonical()); - return table1.addColumn(column.getId().getCanonical(), node, framework.getTypeFactory()); + column.setVtName(column.getId().getDisplay()); + return table1.addColumn(column.getId().getDisplay(), node, framework.getTypeFactory()); } else { throw new RuntimeException(); } } public class SqrlToSql implements SqlRelationVisitor { - final AtomicInteger pkId = new AtomicInteger(0); public Result rewrite(SqlNode query, boolean materializeSelf, List currentPath) { Context context = new Context(materializeSelf, currentPath, new HashMap<>(), false, currentPath.size() > 0, false); @@ -527,7 +526,8 @@ public Result visitTable(SqrlCompoundIdentifier node, Context context) { if (isNested) { RelOptTable table = planner.getCatalogReader().getSqrlTable(pathWalker.getAbsolutePath()); pullupColumns = IntStream.range(0, table.getKeys().get(0).asSet().size()) - .mapToObj(i -> "__" + table.getRowType().getFieldList().get(i).getName() + "$pk$" + pkId.incrementAndGet()) + .mapToObj(i -> "__" + table.getRowType().getFieldList().get(i).getName() + "$pk$" + + planner.getUniqueMacroInt().incrementAndGet()) .collect(Collectors.toList()); } } else { //treat self as a parameterized binding to the next function diff --git a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/plan/rel/LogicalStream.java b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/plan/rel/LogicalStream.java index ad357cc3a..8a0066b06 100644 --- a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/plan/rel/LogicalStream.java +++ b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/plan/rel/LogicalStream.java @@ -73,10 +73,10 @@ public static RelDataType deriveRowType(RelDataTypeFactory typeFactory, RelDataT RelDataTypeFactory.Builder builder = typeFactory.builder(); Set containedNames = new HashSet(); - builder.add(ReservedName.UUID.getCanonical()+"$0", makeUuidType(typeFactory, false)); - builder.add(ReservedName.SOURCE_TIME.getCanonical()+"$0", makeTimestampType(typeFactory,false)); - containedNames.add(ReservedName.UUID.getCanonical()+"$0"); - containedNames.add(ReservedName.SOURCE_TIME.getCanonical()+"$0"); + builder.add(ReservedName.UUID.getCanonical(), makeUuidType(typeFactory, false)); + builder.add(ReservedName.SOURCE_TIME.getCanonical(), makeTimestampType(typeFactory,false)); + containedNames.add(ReservedName.UUID.getCanonical()); + containedNames.add(ReservedName.SOURCE_TIME.getCanonical()); List fieldList = inputRowType.getFieldList(); diff --git a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/Field.java b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/Field.java index bf5c743e2..10b162393 100644 --- a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/Field.java +++ b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/Field.java @@ -24,7 +24,7 @@ protected Field(@NonNull Name name, int version) { } public Name getId() { - return name.suffix(Integer.toString(version)); + return name; } public boolean isVisible() { diff --git a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/SQRLTable.java b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/SQRLTable.java index 7482fd8ac..37bea128f 100644 --- a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/SQRLTable.java +++ b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/SQRLTable.java @@ -51,10 +51,7 @@ public int getNextFieldVersion(Name name) { public Column addColumn(Name name, String vtName, boolean visible, RelDataType type) { //extract version information from vt column or derive a new version - int version = name.getCanonical().split("\\$").length > 1 ? - Integer.parseInt(name.getCanonical().split("\\$")[1]) : getNextFieldVersion(name); - - Column col = new Column(name, version, visible, type); + Column col = new Column(name, 0, visible, type); col.setVtName(vtName); fields.addField(col); return col; diff --git a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/UniversalTable.java b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/UniversalTable.java index 775d2470c..ada6fa44c 100644 --- a/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/UniversalTable.java +++ b/sqrl-planner/sqrl-common/src/main/java/com/datasqrl/schema/UniversalTable.java @@ -89,15 +89,10 @@ public void addColumn(final Name colName, RelDataType type) { } public void addColumn(Name colName, RelDataType type, boolean visible) { - //column may already be versioned, if so, strip - String nameStr = colName.getCanonical().split("\\$")[0]; - Preconditions.checkState(!nameStr.isEmpty(), "Column not named: " + colName); - Name name = Name.system(nameStr); - - int version = fields.nextVersion(name); + int version = fields.nextVersion(colName); //A name may clash with a previously added name, hence we increase the version - fields.addField(new Column(name, version, type, visible)); + fields.addField(new Column(colName, version, type, visible)); } public void addChild(Name name, UniversalTable child, Multiplicity multiplicity) { @@ -156,7 +151,7 @@ public List> convert(TypeConverter converter, boolean inc return fields.getFields(false) .filter(f -> (includeNested || (f instanceof Column)) && (!onlyVisible || f.isVisible())) .map(f -> { - String name = f.getId().getCanonical(); + String name = f.getId().getDisplay(); T type; if (f instanceof Column) { Column column = (Column) f; diff --git a/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/inference/SchemaBuilder.java b/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/inference/SchemaBuilder.java index 79f0b05c9..194cdd006 100644 --- a/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/inference/SchemaBuilder.java +++ b/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/inference/SchemaBuilder.java @@ -198,7 +198,7 @@ public Coords visitObjectField(InferredObjectField field, Object context) { InputValueDefinition def; if (parameter.isInternal()) { List collect = field.getParentTable().getColumns(false).stream() - .map(f->f.getId().getCanonical()) + .map(f->f.getId().getDisplay()) .collect(Collectors.toList()); int i = framework.getCatalogReader().nameMatcher() .indexOf(collect, parameter.getName()); diff --git a/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/inference/SchemaInference.java b/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/inference/SchemaInference.java index cc5e5c18f..0ed45ada5 100644 --- a/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/inference/SchemaInference.java +++ b/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/inference/SchemaInference.java @@ -557,7 +557,7 @@ private InferredSubscriptions resolveSubscriptions(ObjectTypeDefinition s) { Map filters = new HashMap<>(); for (InputValueDefinition input : def.getInputValueDefinitions()) { Name fieldId = table.getField(Name.system(input.getName())).get().getId(); - filters.put(input.getName(), fieldId.getCanonical()); + filters.put(input.getName(), fieldId.getDisplay()); } /** * Match parameters, error if there are any on the sqrl function diff --git a/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/util/ReplaceGraphqlQueries.java b/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/util/ReplaceGraphqlQueries.java index e0df557a3..29b21459f 100644 --- a/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/util/ReplaceGraphqlQueries.java +++ b/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/graphql/util/ReplaceGraphqlQueries.java @@ -63,7 +63,8 @@ public JdbcQuery visitApiQuery(ApiQueryBase apiQueryBase, Object context) { QueryTemplate template = queries.get(apiQueryBase.getQuery()); String query = planner.relToString(Dialect.POSTGRES, - planner.convertRelToDialect(Dialect.POSTGRES, template.getRelNode())); + planner.convertRelToDialect(Dialect.POSTGRES, template.getRelNode())) + .replaceAll("\"", ""); return JdbcQuery.builder() .parameters(apiQueryBase.getParameters()) @@ -76,7 +77,8 @@ public JdbcQuery visitPagedApiQuery(PagedApiQueryBase apiQueryBase, Object conte QueryTemplate template = queries.get(apiQueryBase.getQuery()); String query = planner.relToString(Dialect.POSTGRES, - planner.convertRelToDialect(Dialect.POSTGRES, template.getRelNode())); + planner.convertRelToDialect(Dialect.POSTGRES, template.getRelNode())) + .replaceAll("\"", ""); int numDynamParams = countParameters(template.getRelNode()); //number of params may have extra internal params but never less diff --git a/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/plan/SqrlPlanningTableFactory.java b/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/plan/SqrlPlanningTableFactory.java index 955116b52..25b037b2c 100644 --- a/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/plan/SqrlPlanningTableFactory.java +++ b/sqrl-planner/sqrl-planner-local/src/main/java/com/datasqrl/plan/SqrlPlanningTableFactory.java @@ -20,6 +20,7 @@ import com.datasqrl.schema.SQRLTable; import com.datasqrl.util.SqlNameUtil; import com.datasqrl.util.StreamUtil; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.function.Supplier; @@ -71,10 +72,8 @@ public void createTable(List path, RelNode input, List hints, AnnotatedLP processedRel = analyzedLP.getConvertedRelnode(); - List relFieldNames = processedRel.getRelNode().getRowType().getFieldNames().stream() - //todo: one versioned field comes in with a distinct on statement, fix it and remove this line - .map(s->s.contains("$") ? s.split("\\$")[0] : s) //remove version info - .collect(Collectors.toList()); + List relFieldNames = new ArrayList<>( + processedRel.getRelNode().getRowType().getFieldNames()); List fieldNames = processedRel.getSelect().targetsAsList().stream() .map(idx -> relFieldNames.get(idx)) diff --git a/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/AbstractPhysicalSQRLIT.java b/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/AbstractPhysicalSQRLIT.java index 079fd8122..62f58a18e 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/AbstractPhysicalSQRLIT.java +++ b/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/AbstractPhysicalSQRLIT.java @@ -174,7 +174,7 @@ protected void validateTables(String script, Collection queryTables, typeFilter = filterOutTimestampColumn; } String content = Arrays.stream(ResultSetPrinter.toLines(resultSet, - s -> !ReservedName.UUID.matches(s) && !ReservedName.INGEST_TIME.matches(s) && !Name.isSystemHidden(s), + s -> !s.startsWith(ReservedName.UUID.getCanonical()) && !ReservedName.INGEST_TIME.matches(s) && !Name.isSystemHidden(s), typeFilter)) .sorted().collect(Collectors.joining(System.lineSeparator())); snapshot.addContent(content, query.getNameId(), "data"); diff --git a/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/util/TestScript.java b/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/util/TestScript.java index eb8c5d3f6..d0c3906bb 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/util/TestScript.java +++ b/sqrl-planner/sqrl-planner-local/src/test/java/com/datasqrl/util/TestScript.java @@ -169,7 +169,6 @@ public Stream provideArguments(ExtensionContext extensionCo } } - List jdbcEngines = List.of(DatabaseEngine.H2, - DatabaseEngine.POSTGRES, DatabaseEngine.SQLITE); + List jdbcEngines = List.of(DatabaseEngine.POSTGRES); } diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/absoluteTest1.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/absoluteTest1.txt index 510b43574..c1091202c 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/absoluteTest1.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/absoluteTest1.txt @@ -1,7 +1,7 @@ >>>product$q$2 LogicalTableScan(table=[[product$i$1]]) ->>>x$q$5 -LogicalProject(_uuid$0=[$0], productid=[$2], _ingest_time$0=[$1]) +>>>x$q$4 +LogicalProject(_uuid=[$0], productid=[$2], _ingest_time=[$1]) LogicalTableScan(table=[[product$q$2]]) diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/absoluteTest2.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/absoluteTest2.txt index 42434fcb3..87494f680 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/absoluteTest2.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/absoluteTest2.txt @@ -1,11 +1,11 @@ >>>orders$q$2 LogicalTableScan(table=[[orders$i$1]]) ->>>x$q$10 -LogicalProject(_uuid$0=[$0], _idx$0=[$6], discount=[$10], time$0=[$4]) +>>>x$q$9 +LogicalProject(_uuid=[$0], _idx=[$6], discount=[$10], time=[$4]) LogicalCorrelate(correlation=[$cor3], joinType=[inner], requiredColumns=[{5}]) LogicalTableScan(table=[[orders$q$2]]) Uncollect - LogicalProject($f0=[$cor3.entries$0]) + LogicalProject($f0=[$cor3.entries]) LogicalValues(tuples=[[{ 0 }]]) diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/accessTableFunctionTest.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/accessTableFunctionTest.txt index c7cbb8e7d..f5b88bf0d 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/accessTableFunctionTest.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/accessTableFunctionTest.txt @@ -1,9 +1,9 @@ >>>customer$q$2 LogicalTableScan(table=[[customer$i$1]]) ->>>orders$q$6 -LogicalTableScan(table=[[orders$i$5]]) +>>>orders$q$5 +LogicalTableScan(table=[[orders$i$4]]) ->>>product$q$15 -LogicalTableScan(table=[[product$i$14]]) +>>>product$q$13 +LogicalTableScan(table=[[product$i$12]]) diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/aggregateIsToOne.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/aggregateIsToOne.txt index 3fe7c40b6..2f63e3cda 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/aggregateIsToOne.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/aggregateIsToOne.txt @@ -1,18 +1,18 @@ >>>orders$q$2 LogicalTableScan(table=[[orders$i$1]]) ->>>stats$q$10 -LogicalProject(___uuid$0$pk$1=[$0], num=[$2], total=[$3], time$0=[$1]) +>>>stats$q$9 +LogicalProject(___uuid$pk$1=[$0], num=[$2], total=[$3], time=[$1]) LogicalAggregate(group=[{0, 4}], num=[COUNT()], total=[SUM($10)]) LogicalCorrelate(correlation=[$cor1], joinType=[inner], requiredColumns=[{5}]) LogicalTableScan(table=[[orders$q$2]]) Uncollect - LogicalProject($f0=[$cor1.entries$0]) + LogicalProject($f0=[$cor1.entries]) LogicalValues(tuples=[[{ 0 }]]) ->>>x$q$15 -LogicalProject(_uuid$0=[$0], id=[$2], customerid=[$3], num=[$7], time$0=[$4]) +>>>x$q$13 +LogicalProject(_uuid=[$0], id=[$2], customerid=[$3], num=[$7], time=[$4]) LogicalJoin(condition=[AND(=($0, $6), =($9, $4))], joinType=[left]) LogicalTableScan(table=[[orders$q$2]]) - LogicalTableScan(table=[[stats$q$10]]) + LogicalTableScan(table=[[stats$q$9]]) diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/aggregateIsToOne2.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/aggregateIsToOne2.txt index 3fe7c40b6..2f63e3cda 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/aggregateIsToOne2.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/aggregateIsToOne2.txt @@ -1,18 +1,18 @@ >>>orders$q$2 LogicalTableScan(table=[[orders$i$1]]) ->>>stats$q$10 -LogicalProject(___uuid$0$pk$1=[$0], num=[$2], total=[$3], time$0=[$1]) +>>>stats$q$9 +LogicalProject(___uuid$pk$1=[$0], num=[$2], total=[$3], time=[$1]) LogicalAggregate(group=[{0, 4}], num=[COUNT()], total=[SUM($10)]) LogicalCorrelate(correlation=[$cor1], joinType=[inner], requiredColumns=[{5}]) LogicalTableScan(table=[[orders$q$2]]) Uncollect - LogicalProject($f0=[$cor1.entries$0]) + LogicalProject($f0=[$cor1.entries]) LogicalValues(tuples=[[{ 0 }]]) ->>>x$q$15 -LogicalProject(_uuid$0=[$0], id=[$2], customerid=[$3], num=[$7], time$0=[$4]) +>>>x$q$13 +LogicalProject(_uuid=[$0], id=[$2], customerid=[$3], num=[$7], time=[$4]) LogicalJoin(condition=[AND(=($0, $6), =($9, $4))], joinType=[left]) LogicalTableScan(table=[[orders$q$2]]) - LogicalTableScan(table=[[stats$q$10]]) + LogicalTableScan(table=[[stats$q$9]]) diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/assignmentHintTest.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/assignmentHintTest.txt index b70b2fe60..2822dbf12 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/assignmentHintTest.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/assignmentHintTest.txt @@ -1,11 +1,11 @@ >>>orders$q$2 LogicalTableScan(table=[[orders$i$1]]) ->>>x$q$10 -LogicalProject(_uuid$0=[$0], _idx$0=[$6], productid$0=[$7], quantity$0=[$8], unit_price$0=[$9], discount$0=[$10], time$0=[$4]) +>>>x$q$9 +LogicalProject(_uuid=[$0], _idx=[$6], productid=[$7], quantity=[$8], unit_price=[$9], discount=[$10], time=[$4]) LogicalCorrelate(correlation=[$cor3], joinType=[inner], requiredColumns=[{5}]) LogicalTableScan(table=[[orders$q$2]]) Uncollect - LogicalProject($f0=[$cor3.entries$0]) + LogicalProject($f0=[$cor3.entries]) LogicalValues(tuples=[[{ 0 }]]) diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/caseWhenTest.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/caseWhenTest.txt index b067768fe..cacc125a4 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/caseWhenTest.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/caseWhenTest.txt @@ -1,17 +1,17 @@ >>>customer$q$2 LogicalTableScan(table=[[customer$i$1]]) ->>>customernames$q$18 -LogicalProject(_uuid$0=[$0], _idx$0=[$6], productid$0=[$7], quantity$0=[$8], unit_price$0=[$9], discount$0=[$10], time$0=[$4], EXPR$6=[CASE(IS NULL($10), 0:DOUBLE, $10)]) +>>>customernames$q$15 +LogicalProject(_uuid=[$0], _idx=[$6], productid=[$7], quantity=[$8], unit_price=[$9], discount=[$10], time=[$4], EXPR$6=[CASE(IS NULL($10), 0:DOUBLE, $10)]) LogicalCorrelate(correlation=[$cor3], joinType=[inner], requiredColumns=[{5}]) - LogicalTableScan(table=[[orders$q$6]]) + LogicalTableScan(table=[[orders$q$5]]) Uncollect - LogicalProject($f0=[$cor3.entries$0]) + LogicalProject($f0=[$cor3.entries]) LogicalValues(tuples=[[{ 0 }]]) ->>>orders$q$6 -LogicalTableScan(table=[[orders$i$5]]) +>>>orders$q$5 +LogicalTableScan(table=[[orders$i$4]]) ->>>product$q$15 -LogicalTableScan(table=[[product$i$14]]) +>>>product$q$13 +LogicalTableScan(table=[[product$i$12]]) diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/castExpression.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/castExpression.txt index 7c794358b..6496d08f6 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/castExpression.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/castExpression.txt @@ -1,7 +1,7 @@ ->>>orders$q$10 -LogicalProject(_uuid$0=[$0], x=['1':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], _ingest_time$0=[$1], id$0=[$2], customerid$0=[$3], time$0=[$4]) - LogicalTableScan(table=[[orders$q$2]]) - >>>orders$q$2 LogicalTableScan(table=[[orders$i$1]]) +>>>orders$q$9 +LogicalProject(_uuid=[$0], x=['1':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], _ingest_time=[$1], id=[$2], customerid=[$3], time=[$4], entries=[$5]) + LogicalTableScan(table=[[orders$q$2]]) + diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/castTest.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/castTest.txt index 42e65f044..69fc78fd1 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/castTest.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/castTest.txt @@ -1,23 +1,23 @@ >>>orders$q$2 LogicalTableScan(table=[[orders$i$1]]) ->>>x$q$10 -LogicalProject(_uuid$0=[$0], cast1=['1':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], time$0=[$4]) +>>>x$q$11 +LogicalProject(_uuid=[$0], cast2=[false], time=[$4]) LogicalTableScan(table=[[orders$q$2]]) >>>x$q$13 -LogicalProject(_uuid$0=[$0], cast2=[false], time$0=[$4]) +LogicalProject(_uuid=[$0], cast3=[1:DOUBLE], time=[$4]) LogicalTableScan(table=[[orders$q$2]]) ->>>x$q$16 -LogicalProject(_uuid$0=[$0], cast3=[1:DOUBLE], time$0=[$4]) +>>>x$q$15 +LogicalProject(_uuid=[$0], cast4=[1:BIGINT], time=[$4]) LogicalTableScan(table=[[orders$q$2]]) ->>>x$q$19 -LogicalProject(_uuid$0=[$0], cast4=[1:BIGINT], time$0=[$4]) +>>>x$q$17 +LogicalProject(_uuid=[$0], cast5=[1970-01-01 00:00:00.001:TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)], time=[$4]) LogicalTableScan(table=[[orders$q$2]]) ->>>x$q$22 -LogicalProject(_uuid$0=[$0], cast5=[1970-01-01 00:00:00.001:TIMESTAMP_WITH_LOCAL_TIME_ZONE(3)], time$0=[$4]) +>>>x$q$9 +LogicalProject(_uuid=[$0], cast1=['1':VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], time=[$4]) LogicalTableScan(table=[[orders$q$2]]) diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/categoryTest.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/categoryTest.txt index 60311b857..ee79e56e1 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/categoryTest.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/categoryTest.txt @@ -1,13 +1,13 @@ ->>>category$q$18 -LogicalProject(name=[$5], _ingest_time$0=[$1]) - LogicalTableScan(table=[[product$q$15]]) +>>>category$q$15 +LogicalProject(name=[$5], _ingest_time=[$1]) + LogicalTableScan(table=[[product$q$13]]) >>>customer$q$2 LogicalTableScan(table=[[customer$i$1]]) ->>>orders$q$6 -LogicalTableScan(table=[[orders$i$5]]) +>>>orders$q$5 +LogicalTableScan(table=[[orders$i$4]]) ->>>product$q$15 -LogicalTableScan(table=[[product$i$14]]) +>>>product$q$13 +LogicalTableScan(table=[[product$i$12]]) diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/coalesceTest.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/coalesceTest.txt index 0ad796bb4..93b6b87b9 100644 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/coalesceTest.txt +++ b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/coalesceTest.txt @@ -1,9 +1,9 @@ ->>>entries$q$10 -LogicalProject(___uuid$0$pk$1=[$0], _idx$0=[$6], discount2=[CASE(IS NOT NULL($10), CAST($10):DOUBLE NOT NULL, 0.0:DOUBLE)], ___uuid$0$pk$10=[$0], _uuid$0=[$0], productid$0=[$7], quantity$0=[$8], unit_price$0=[$9], discount$0=[$10], time$0=[$4]) +>>>entries$q$9 +LogicalProject(___uuid$pk$1=[$0], _idx=[$6], discount2=[CASE(IS NOT NULL($10), CAST($10):DOUBLE NOT NULL, 0.0:DOUBLE)], ___uuid$pk$10=[$0], _uuid=[$0], productid=[$7], quantity=[$8], unit_price=[$9], discount=[$10], time=[$4]) LogicalCorrelate(correlation=[$cor3], joinType=[inner], requiredColumns=[{5}]) LogicalTableScan(table=[[orders$q$2]]) Uncollect - LogicalProject($f0=[$cor3.entries$0]) + LogicalProject($f0=[$cor3.entries]) LogicalValues(tuples=[[{ 0 }]]) >>>orders$q$2 diff --git a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/compoundAggregateExpressionTest.txt b/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/compoundAggregateExpressionTest.txt deleted file mode 100644 index 0dbd5dd8f..000000000 --- a/sqrl-planner/sqrl-planner-local/src/test/resources/snapshots/com/datasqrl/plan/local/analyze/QuerySnapshotTest/compoundAggregateExpressionTest.txt +++ /dev/null @@ -1,7 +0,0 @@ ->>>errors -[FATAL] Could not plan expression: Expression is not simple -in script: