Skip to content

Commit 709ab9c

Browse files
mihaibudiugz
authored andcommitted
[SQL] Do not take references of expressions in LazyCell initializers
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
1 parent 36b0b71 commit 709ab9c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/rust/ToRustInnerVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,7 @@ public VisitDecision preorder(DBSPFieldExpression expression) {
22652265
// We are explicitly taking a reference for these cases
22662266
avoidRef = true;
22672267
}
2268-
} else if (parent.is(DBSPBorrowExpression.class)) {
2268+
} else if (parent.is(DBSPBorrowExpression.class) || parent.is(DBSPLazyExpression.class)) {
22692269
// Pattern appearing in aggregation
22702270
avoidRef = true;
22712271
}

sql-to-dbsp-compiler/SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/sql/simple/Regression2Tests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,4 +806,21 @@ CREATE TABLE purchase (
806806
SUM(value) OVER (ORDER BY ts ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS rolling_sum
807807
FROM purchase;""", "Not yet implemented: Window aggregates with ROWS");
808808
}
809+
810+
@Test
811+
public void jsonTests() {
812+
this.getCCS("""
813+
CREATE TYPE c_t AS ("value" VARCHAR);
814+
CREATE TYPE b_t AS ("x" c_t, "y" c_t);
815+
CREATE TYPE a_t AS ("b" b_t);
816+
CREATE FUNCTION jsonstring_as_a_t(input VARCHAR) RETURNS a_t;
817+
818+
CREATE TABLE src ("data" VARCHAR);
819+
820+
CREATE VIEW v AS
821+
SELECT
822+
jsonstring_as_a_t("data")."b"."x"."value" AS "x_val",
823+
jsonstring_as_a_t("data")."b"."y"."value" AS "y_val"
824+
FROM src;""");
825+
}
809826
}

0 commit comments

Comments
 (0)