-
Notifications
You must be signed in to change notification settings - Fork 292
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
Scripts table should be created for each database/schema #665
Comments
I want to try this task, please assign this task to me if you don't mind. |
@ShenJunkun assigned |
We could reserve a schema for all built-in tables, such as a schema named |
This is my plan:
I also have some questions.
|
There are several approaches Reserve one scripts table in the system schema
Drawbacks
select script from catalog.system.scripts where name='xxx';
select script from catalog.system.scripts where name='xxx' and schema='xxx'; But this could be improved by putting the scripts table or the system catalog in the search path like PostgreSQL
Reserve scripts table for each schema in the system schema
Drawbacks
select script from catalogName_schemaName_scripts where name = 'xxx'; Maybe we need to use a fully qualified name as we are in a different catalog/schema select script from greptime.system.catalogName_schemaName_scripts where name = 'xxx'; Actually, we could reserve a system schema for each catalog, so the Reserve scripts table for each schema
We need to create this table for each schema, then we could access it by typing its name directly select script from gt_scripts where name = 'xxx'; DrawbackWe need to create the table for each schema, which also means that there are lots of scripts table ConclusionAs for me, I'd prefer the first solution: putting all system tables, including the scripts table in a specific schema. Generally, we don't recommend users operate the system tables directly. We should provide SQL commands or API to do that
I'd be happy to hear your thoughts @sunng87 @killme2008 @ShenJunkun |
I think we could implement this in
You might need to create a distributed table, as mentioned in this |
Sounds reasonable! By the way, Is there a difference between a |
Oops, @MichaelScofield is refactoring our gPRC protocol, so I'm afraid that the distributed mode may not work until #381 is done
Catalog and schema are different in GreptimeDB. But there are still some works to be done if we'd like to support creating a catalog/schema via SQL manually. |
I prefer the first solution too. Let's do it. |
Yes, this is the key issue I have been concerning about. In MySQL schema == database, while in Postgres and some other databases, catalog == database, schema is namespace of a few tables. In GreptimeDB, we follow MySQL convention to treat schema as database: by running From my perspective, I want to keep database self-contained, to be the minimum isolation unit in shared environment, which means:
So that's the reason I'm +1 for storing scripts as built-in table for each schema(database). But I agree this approach has its cons for example the table is visible and modifiable to user. |
That's a trade-off! We can discuss about it. @killme2008 @sunng87 @evenyag
Never mind! |
@sunng87 @ShenJunkun After taking a brief look at the codes, I find out that adding a greptimedb/src/script/src/table.rs Lines 68 to 72 in 7762873
To support schema isolation, we just need to specify the schema column in greptimedb/src/script/src/table.rs Line 87 in 7762873
greptimedb/src/script/src/table.rs Lines 142 to 146 in 7762873
But the catalog manager itself doesn't support creating the system tables for each new schema now. I think we can fix this issue by simply adding a greptimedb/src/script/src/table.rs Lines 54 to 58 in 7762873
Maybe we need to move the scripts table to the system catalog like this system table greptimedb/src/catalog/src/system.rs Lines 104 to 108 in 7762873
For distributed mode, we need some other ways to implement system tables, which is out of the topic.
Actually, the script operation is only available under the HTTP API, so it's meaningless for users to access the table directly. So it should be fine that we only have one script table now. |
Agreed. Let's use system schema to store scripts and use a |
Ok, let's do it! |
Another question: When I try to use sql to access the log show that:
|
What data do you want to get from this table? Now we don't support reading the contents in this table via the SQL interface, so you might need to implement I think we should hide |
If I move scripts table to
|
It's recommended. We need a way to list stored scripts for a database. It can either be done via a Http REST API, or a dedicated SQL statement like |
I think we could create another issue for this feature and do it later |
There are two tasks to be finished:
|
@ShenJunkun Hi Junkun, this is April from Greptime Devrel team, Thanks a lot for your contribution in our community!! Do you mind joining our Slack https://greptime.com/slack or leaving your email address? so we can contact you and send you important notices. Thanks a lot! |
I have already joined GreptimeDB slack. My email address is |
What type of enhancement is this?
Refactor
What does the enhancement do?
The
scripts
table, where we stored python scripts, should be created for each database/schema. This can either be done when creating the database/schema, or lazily created on first script register request.Also we need a special naming pattern for these built-in tables, for example, to be prefixed with
_
orgt_
.Implementation challenges
No response
The text was updated successfully, but these errors were encountered: