-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add support for SHOW CREATE SCHEMA #24356
base: master
Are you sure you want to change the base?
Conversation
Codenotify: Notifying subscribers in CODENOTIFY files for diff b511e7a...dd9494c.
|
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.
Thanks! Pull branch, local doc build, everything looks good.
Thanks for the release note! A couple of nits.
|
68ef2bb
to
8794ad6
Compare
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.
one minor nit. Otherwise, could we add some negative tests for the case a user specifies only a catalog or a table directly and verify that the query fails?
} | ||
|
||
Map<String, Object> properties = metadata.getSchemaProperties(session, catalogSchemaName); | ||
Map<String, PropertyMetadata<?>> allTableProperties = metadata.getSchemaPropertyManager().getAllProperties().get(getConnectorIdOrThrow(session, metadata, catalogSchemaName.getCatalogName())); |
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.
nit: allSchemaProperties
?
8794ad6
to
dd9494c
Compare
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.
Thanks for this change. One little problem and one point for discussing, otherwise looks good to me.
if (node.getType() == SCHEMA) { | ||
CatalogSchemaName catalogSchemaName = createCatalogSchemaName(session, node, Optional.of(node.getName())); | ||
if (!metadataResolver.schemaExists(catalogSchemaName)) { | ||
throw new SemanticException(MISSING_SCHEMA, node, "Schema '%s' does not exist", catalogSchemaName); | ||
} | ||
|
||
Map<String, Object> properties = metadata.getSchemaProperties(session, catalogSchemaName); | ||
Map<String, PropertyMetadata<?>> allSchemaProperties = metadata.getSchemaPropertyManager().getAllProperties().get(getConnectorIdOrThrow(session, metadata, catalogSchemaName.getCatalogName())); | ||
List<Property> propertyNodes = buildProperties(objectName, Optional.empty(), INVALID_SCHEMA_PROPERTY, properties, allSchemaProperties); | ||
CreateSchema createSchema = new CreateSchema( | ||
node.getName(), | ||
false, | ||
propertyNodes); | ||
return singleValueQuery("Create Schema", formatSql(createSchema, Optional.of(parameters)).trim()); | ||
} |
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.
Is it better to put this code at the beginning of the method? As far as I can see, createQualifiedObjectName(session, node, node.getName())
will fail when we just provide catalogname.schemaname
in a session which do not set default catalog and schema. So, if we connector the database without set a default schema, then executing the following statements:
show create schema hive.default;
We will fail with the following message: Catalog must be specified when session catalog is not set
.
Moreover, when executing show create schema
, there is no need to execute getView(...)
and getMaterializedView(...)
firstly.
|
||
public static Map<String, Object> getDatabaseProperties(Database database) | ||
{ | ||
ImmutableMap.Builder<String, Object> result = ImmutableMap.builder(); | ||
database.getLocation().ifPresent(location -> result.put(LOCATION_PROPERTY, location)); | ||
return result.build(); | ||
} |
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.
Do you think it makes sense to move this class to presto-hive-metastore
? Seems it's more like a concept of HMS.
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.
I think that's a good idea. Let me refactor it in different PR and then I can rebase this one
#24401
Description
Add support for SHOW CREATE SCHEMA
SHOW CREATE SCHEMA
SHOW CREATE SCHEMA
in hive & iceberg connectorMotivation and Context
There was no way to check schema properties. So this SQL support will provide a way to check properties like
location
for schemaImpact
SQL support for
SHOW CREATE SCHEMA
from a schema :Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.