rdblue commented on code in PR #6428: URL: https://github.com/apache/iceberg/pull/6428#discussion_r1051679882
########## snowflake/src/main/java/org/apache/iceberg/snowflake/entities/SnowflakeIdentifier.java: ########## @@ -0,0 +1,167 @@ +/* + * 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.iceberg.snowflake.entities; + +import java.util.List; +import org.apache.commons.dbutils.ResultSetHandler; +import org.apache.iceberg.relocated.com.google.common.base.Objects; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.relocated.com.google.common.collect.Lists; + +public class SnowflakeIdentifier { + public enum Type { + ROOT, + DATABASE, + SCHEMA, + TABLE + } + + private String databaseName; + private String schemaName; + private String tableName; + + protected SnowflakeIdentifier(String databaseName, String schemaName, String tableName) { + this.databaseName = databaseName; + this.schemaName = schemaName; + this.tableName = tableName; + } + + public static SnowflakeIdentifier ofRoot() { + return new SnowflakeIdentifier(null, null, null); + } + + public static SnowflakeIdentifier ofDatabase(String databaseName) { + Preconditions.checkArgument(null != databaseName, "databaseName must be non-null"); + return new SnowflakeIdentifier(databaseName, null, null); + } + + public static SnowflakeIdentifier ofSchema(String databaseName, String schemaName) { + Preconditions.checkArgument(null != databaseName, "databaseName must be non-null"); + Preconditions.checkArgument(null != schemaName, "schemaName must be non-null"); + return new SnowflakeIdentifier(databaseName, schemaName, null); + } + + public static SnowflakeIdentifier ofTable( + String databaseName, String schemaName, String tableName) { + Preconditions.checkArgument(null != databaseName, "databaseName must be non-null"); + Preconditions.checkArgument(null != schemaName, "schemaName must be non-null"); + Preconditions.checkArgument(null != tableName, "tableName must be non-null"); + return new SnowflakeIdentifier(databaseName, schemaName, tableName); + } + + /** + * If type is TABLE, expect non-null databaseName, schemaName, and tableName. If type is SCHEMA, + * expect non-null databaseName and schemaName. If type is DATABASE, expect non-null databaseName. + * If type is ROOT, expect all of databaseName, schemaName, and tableName to be null. + */ + public Type getType() { + if (null != tableName) { + return Type.TABLE; + } else if (null != schemaName) { + return Type.SCHEMA; + } else if (null != databaseName) { + return Type.DATABASE; + } else { + return Type.ROOT; + } + } + + public String getTableName() { Review Comment: Iceberg does not use `get` in method names. Either it isn't helpful and can be omitted, or it should be replaced with a more specific verb. It's arguable that no one will touch this code besides Snowflake so it is okay, but I'd still recommend conforming to the project style. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
