|
||||
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 package org.apache.spark.sql.connector.catalog; 0019 0020 import org.apache.spark.annotation.Evolving; 0021 0022 /** 0023 * NamespaceChange subclasses represent requested changes to a namespace. These are passed to 0024 * {@link SupportsNamespaces#alterNamespace}. For example, 0025 * <pre> 0026 * import NamespaceChange._ 0027 * val catalog = Catalogs.load(name) 0028 * catalog.alterNamespace(ident, 0029 * setProperty("prop", "value"), 0030 * removeProperty("other_prop") 0031 * ) 0032 * </pre> 0033 * 0034 * @since 3.0.0 0035 */ 0036 @Evolving 0037 public interface NamespaceChange { 0038 /** 0039 * Create a NamespaceChange for setting a namespace property. 0040 * <p> 0041 * If the property already exists, it will be replaced with the new value. 0042 * 0043 * @param property the property name 0044 * @param value the new property value 0045 * @return a NamespaceChange for the addition 0046 */ 0047 static NamespaceChange setProperty(String property, String value) { 0048 return new SetProperty(property, value); 0049 } 0050 0051 /** 0052 * Create a NamespaceChange for removing a namespace property. 0053 * <p> 0054 * If the property does not exist, the change will succeed. 0055 * 0056 * @param property the property name 0057 * @return a NamespaceChange for the addition 0058 */ 0059 static NamespaceChange removeProperty(String property) { 0060 return new RemoveProperty(property); 0061 } 0062 0063 /** 0064 * A NamespaceChange to set a namespace property. 0065 * <p> 0066 * If the property already exists, it must be replaced with the new value. 0067 */ 0068 final class SetProperty implements NamespaceChange { 0069 private final String property; 0070 private final String value; 0071 0072 private SetProperty(String property, String value) { 0073 this.property = property; 0074 this.value = value; 0075 } 0076 0077 public String property() { 0078 return property; 0079 } 0080 0081 public String value() { 0082 return value; 0083 } 0084 } 0085 0086 /** 0087 * A NamespaceChange to remove a namespace property. 0088 * <p> 0089 * If the property does not exist, the change should succeed. 0090 */ 0091 final class RemoveProperty implements NamespaceChange { 0092 private final String property; 0093 0094 private RemoveProperty(String property) { 0095 this.property = property; 0096 } 0097 0098 public String property() { 0099 return property; 0100 } 0101 } 0102 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |