Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support table functions in SQL #391

Merged
merged 8 commits into from
Oct 30, 2023
Merged

Support table functions in SQL #391

merged 8 commits into from
Oct 30, 2023

Conversation

henneberger
Copy link
Contributor

Initial support for table functions in SQL. Supports calling sqrl table functions but does not impart sqrl native table paths.

IMPORT ecommerce-data.Orders;
X(@id: Int) := SELECT * FROM Orders WHERE id = @id;
X(@id: Int, @customerid: Int) := SELECT * FROM Orders WHERE id = @id AND customerid = @customerid;
Y(@id: Int) := SELECT * FROM TABLE(X(2));
Z(@id: Int) := SELECT * FROM TABLE(X(2, 3));
IMPORT ecommerce-data.Orders;
X(@id: Int) := SELECT * FROM Orders WHERE id = @id;
Y(@id: Int) := SELECT * FROM TABLE(X(@id));
Z := SELECT * FROM TABLE(Y(3));

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

@mbroecheler mbroecheler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome - thanks for getting this to work. It really highlights our contributions to SQL by being able to reuse those functions. Well done!
One minor nit.

@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should call a helper function. We should already have one for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in next commit

@henneberger henneberger merged commit ad0b261 into main Oct 30, 2023
1 check passed
@henneberger henneberger deleted the tableFnc branch October 30, 2023 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants