-
Notifications
You must be signed in to change notification settings - Fork 31
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
Enhance to support named schames in spanner-cli commands #172
Comments
Thank you for filing this issue.
How about making If a user has lots of named schemas to manage multiple tables, it might be tedious to run different commands to get all the tables. As the document says, user needs to use fully qualified name (FQN) to reference a database object in a non-default named schema, so if we can show the table name with FQN, it would be not so weird to show all tables in flat. For example,
|
This is the opinion that it would be better to have a way to list tables across schemas. Named schemas can be context boundaries and may even be access boundaries using FGAC. |
Underlying Query of "show all user tables" SELECT ARRAY_TO_STRING([NULLIF(TABLE_SCHEMA, ""), TABLE_NAME], ".") AS QUALIFIED_TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE (TABLE_CATALOG, TABLE_SCHEMA) IN (
SELECT AS STRUCT CATALOG_NAME, SCHEMA_NAME
FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_OWNER != "spanner_system"
)
ORDER BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME; |
I reconsidered this again and I think that users might use the named schema as a "logical database" while utilizing the database functionalities (such as transactions). So from users perspective, it might not be a big problem to use a different command to show the tables in the named schema because they should be already familiar with the explicit So returning to the first point, I agree your initial proposed behavior.
By the way, I want to be careful to create a new spanner-cli-specific command, so unless we find it extremely useful, I want to defer creating new commands such as |
We have a consensus.
|
For other commands, maybe we can change it to accept fully qualified name (FQN), like |
I agree to use FQN as current |
Currently, there are no handling about named schemas.
I think some commands in spanner-cli that target schema objects need to be extended to support named schemas.
Let's take the
SHOW TABLES
command as an example.The current behavior:
SHOW TABLES;
shows tables only in the default schema.The proposed behavior:
SHOW TABLES;
shows tables only in the default schema.SHOW TABLES <schema>;
shows tables only in the schema namedschema
.Another considerations
SHOW USER TABLES;
shows tables in all user generated schemas(withoutINFORMATION_SCHEMA
,SPANNER_SYS
.SCHEMA_OWNER != "spanner_system"
).SHOW SYSTEM TABLES;
shows tables in all system generated schemas(SCHEMA_OWNER = "spanner_system"
).SHOW ALL TABLES;
shows tables in all schemas(USER + SYSTEM
).SHOW SCHEMAS;
shows all schemas.SHOW SCHEMATA
may not be user friendly.The text was updated successfully, but these errors were encountered: