-
Notifications
You must be signed in to change notification settings - Fork 207
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
feat: table declarations #4126
feat: table declarations #4126
Conversation
5ffdd2e
to
299965f
Compare
1018393
to
2184575
Compare
/// All table references must reside within module at `database_module_path`. | ||
/// They are compiled to table identifiers, using their path relative to the database module. | ||
/// For example, with `database_module_path=my_database`: | ||
/// - `my_database.my_table` will compile to `"my_table"`, | ||
/// - `my_database.my_schema.my_table` will compile to `"my_schema.my_table"`, | ||
/// - `my_table` will error out saying that this table does not reside in current database. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the utility of this? Relative to leaving them as they're specified in the query? (not claiming confidently that there isn't an advantage!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or this will obviate the need for this?
Fully qualified name is used to refer to that table. This will be changed soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds an ability to specify a module as a "database module":
module my_database {
module my_schema {
let my_table <[{}]> # this will be `my_schema.my_table`
}
}
module another_database {
let another_table <[{}]> # this will be `another_database`
}
The problem is that these two tables are defined in two different databases, so they cannot be present in the same query. That's why "current database" is a compiler parameter, so it knows for which database it is compiling for.
Idea being that in the future, we could support querying multiple databases, so PRQL source would compile into multiple queries that would be sent to each of the databases.
e78f4b0
to
c3a7e96
Compare
Closes #2646 with adding support for:
The rule is that any variable declaration with relational type and without an assigned value will be treated as a table in the database.
Fully qualified name is used to refer to that table. This will be changed soon.