-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-48668][SQL] Support ALTER NAMESPACE ... UNSET PROPERTIES in v2 #47038
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
Changes from 1 commit
12f8f71
48e3b44
363ad49
7ddf703
1f3ed06
960f32a
0748ea4
53a9a25
33fbc7c
0d09a65
b3b60ac
0e925c6
87b0bcb
f5efc77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.execution.command | ||
|
|
||
| import org.apache.spark.sql.{Row, SparkSession} | ||
| import org.apache.spark.sql.catalyst.analysis.{ResolveCatalogs, ResolvedIdentifier} | ||
| import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
| import org.apache.spark.sql.connector.catalog.{NamespaceChange, SupportsNamespaces} | ||
| import org.apache.spark.sql.errors.QueryCompilationErrors | ||
|
|
||
| /** | ||
| * A command that ALTER NAMESPACE UNSET PROPERTIES command. | ||
| * | ||
| * The syntax of this command is: | ||
| * {{{ | ||
| * ALTER (DATABASE|SCHEMA|NAMESPACE) ... UNSET (DBPROPERTIES|PROPERTIES) [IF EXISTS] ...; | ||
| * }}} | ||
| */ | ||
| case class UnsetNamespacePropertiesCommand( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to define |
||
| ident: LogicalPlan, | ||
| propKeys: Seq[String], | ||
| ifExists: Boolean) extends UnaryRunnableCommand { | ||
|
|
||
| override def run(sparkSession: SparkSession): Seq[Row] = { | ||
| val ResolvedIdentifier(catalog, ident) = child | ||
| val ns = ResolveCatalogs.resolveNamespace( | ||
| catalog, ident.namespace.toSeq :+ ident.name, fetchMetadata = true) | ||
|
||
| if (!ifExists) { | ||
| val properties = ns.metadata | ||
| val nonexistentKeys = propKeys.filter(key => !properties.contains(key)) | ||
| if (nonexistentKeys.nonEmpty) { | ||
| throw QueryCompilationErrors.unsetNonExistentPropertiesError( | ||
| nonexistentKeys, ns.namespace) | ||
| } | ||
| } | ||
| val changes = propKeys.map { | ||
| NamespaceChange.removeProperty | ||
| } | ||
| catalog match { | ||
| case supportsNS: SupportsNamespaces => | ||
| supportsNS.alterNamespace(ns.namespace.toArray, changes: _*) | ||
| case _ => | ||
| QueryCompilationErrors.catalogOperationNotSupported( | ||
| catalog, "UNSET (DBPROPERTIES|PROPERTIES)") | ||
| } | ||
|
|
||
| Seq.empty | ||
| } | ||
|
|
||
| override def child: LogicalPlan = ident | ||
|
|
||
| override protected def withNewChildInternal( | ||
| newChild: LogicalPlan): UnsetNamespacePropertiesCommand = | ||
| copy(ident = newChild) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
please fix the grammar.
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.
Done