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

STRUCT columns #42

Open
mhfrantz opened this issue Apr 17, 2021 · 2 comments
Open

STRUCT columns #42

mhfrantz opened this issue Apr 17, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@mhfrantz
Copy link

I have a table with a STRUCT column, e.g. STRUCT<x INT64, y INT64>. It looks like Logica variables can only be alphanumeric plus underscore. Is there a way to refer to the fields of a STRUCT? I tried using backticks for the variable name.

@mhfrantz
Copy link
Author

I found one way to do this by aliasing the fields of a STRUCT. For example, if Points is a table containing a point STRUCT with x and y fields:

Points(..r) :- `project.dataset.Points`(..r);

PointsWithX(x: r.point.x, ..r) :- Points(..r);

PointsByX(x:) += 1 :- PointsWithX(x:, point:);

@EvgSkv
Copy link
Owner

EvgSkv commented Apr 18, 2021

That's right, you can access fields of the record with ., just as in Python, C++, etc.

But you don't have to do aliasing, given the table as you described, you can count points by X as follows.

PointsByX(x: point.x) += 1 :- `project.dataset.Points`(point:);

We do need to make sure this is all well documented.

@EvgSkv EvgSkv added the documentation Improvements or additions to documentation label Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants