Skip to content

Commit

Permalink
Add table literal for direct access of nested tables
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Henneberger <git@danielhenneberger.com>
  • Loading branch information
henneberger committed Oct 28, 2023
1 parent f66a179 commit 4d13342
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public void addTable(RootSqrlTable root) {
removePrefix(this.pathToAbsolutePathMap.keySet(),root.getName().toNamePath());
plus().add(String.join(".", root.getPath().toStringList()) + "$"
+ sqrlFramework.getUniqueMacroInt().incrementAndGet(), root);
plus().add(root.getName().getDisplay(), root);
if (!root.getParameters().isEmpty()) {
plus().add(root.getName().getDisplay(), root);
}
}

private void removePrefix(Set<NamePath> set, NamePath prefix) {
Expand All @@ -107,6 +109,9 @@ public void addRelationship(Relationship relationship) {
this.sysTableToRelationshipMap.put(relationship.getFromTable(), relationship);
plus().add(String.join(".", relationship.getPath().toStringList()) + "$"
+ sqrlFramework.getUniqueMacroInt().incrementAndGet(), relationship);
if (!relationship.getParameters().isEmpty()) {
plus().add(String.join(".", relationship.getPath().toStringList()), relationship);
}
}

public void addTableMapping(NamePath path, String nameId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,15 @@ public void chainedTableFncCallTest() {
+ "Y(@id: Int) := SELECT * FROM TABLE(X(@id));\n"
+ "Z := SELECT * FROM TABLE(Y(3));\n");
}


@Test
public void joinTableFncCallTest() {
validateScript("IMPORT ecommerce-data.Orders;\n"
+ "IMPORT ecommerce-data.Product;\n"
+ "Orders.entries.product(@id: Int) := JOIN Product p ON p.productid = @id;\n"
+ "Y(@id: Int) := SELECT * FROM TABLE(`Orders.entries.product`(@id));");
}

@Test
public void lateralJoinTest() {
validateScript("IMPORT ecommerce-data.Orders;\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
>>>orders$2
LogicalTableScan(table=[[orders$1]])

>>>product$2
LogicalTableScan(table=[[product$1]])

>>>y$1
LogicalProject(_uuid=[$0], _ingest_time=[$1], productid=[$2], name=[$3], description=[$4], category=[$5])
LogicalFilter(condition=[=($2, ?0)])
LogicalTableScan(table=[[product$2]])

0 comments on commit 4d13342

Please sign in to comment.