Class SchemaName
- java.lang.Object
-
- com.snowflake.connectors.common.object.SchemaName
-
public class SchemaName extends Object
Representation of a Snowflake schema name.A
SchemaName
object can be a representation of:- an individual schema identifier
- a
db.schema
object
Read more about schema names at Snowflake here.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static SchemaName
from(Identifier schema)
Creates a new schema name instance from the provided schema identifier.static SchemaName
from(Identifier database, Identifier schema)
Creates a new schema name instance from the provided database and schema identifiers.static SchemaName
from(String database, String schema)
Creates a new schema name instance from the provided raw database and schema identifiers.static SchemaName
fromString(String schemaName)
Creates a new schema name instance from the provided raw schema name.Optional<Identifier>
getDatabase()
Returns the database of this schema name.Identifier
getSchema()
Returns the schema of this schema name.String
getValue()
Returns the schema name value.int
hashCode()
boolean
isFullyQualified()
Returns whether this schema name is fully qualified.static boolean
isValid(String schemaName)
Returns whether the provided String is a valid schema name.String
toString()
-
-
-
Method Detail
-
fromString
public static SchemaName fromString(String schemaName)
Creates a new schema name instance from the provided raw schema name.- Parameters:
schemaName
- raw schema name- Returns:
- new schema name instance
- Throws:
InvalidObjectNameException
- if the provided String is not a valid Snowflake schema name
-
from
public static SchemaName from(Identifier schema)
Creates a new schema name instance from the provided schema identifier.- Parameters:
schema
- schema identifier- Returns:
- new schema name instance
- Throws:
InvalidIdentifierException
- if the provided schema identifier is null
-
from
public static SchemaName from(String database, String schema)
Creates a new schema name instance from the provided raw database and schema identifiers.- Parameters:
database
- raw database identifierschema
- raw schema identifier- Returns:
- new schema name instance
- Throws:
InvalidIdentifierException
- if the provided database or schema is not a valid Snowflake identifier
-
from
public static SchemaName from(Identifier database, Identifier schema)
Creates a new schema name instance from the provided database and schema identifiers.- Parameters:
database
- database identifierschema
- schema identifier- Returns:
- new schema name instance
- Throws:
InvalidIdentifierException
- if the provided schema identifier is null
-
isValid
public static boolean isValid(String schemaName)
Returns whether the provided String is a valid schema name.- Parameters:
schemaName
- raw schema name- Returns:
- whether the provided String is a valid schema name
-
getValue
public String getValue()
Returns the schema name value.Returned value is ready to use in any SQL queries, no additional quoting or character escaping is required.
The returned String can be a fully qualified name or a simple unqualified schema name.
The individual identifiers will be converted to String using
Identifier.getValue()
. They may be quoted or unquoted.- Returns:
- SQL-friendly object name
-
isFullyQualified
public boolean isFullyQualified()
Returns whether this schema name is fully qualified.- Returns:
- whether this schema name is fully qualified
-
getDatabase
public Optional<Identifier> getDatabase()
Returns the database of this schema name.- Returns:
- database of this schema name.
-
getSchema
public Identifier getSchema()
Returns the schema of this schema name.- Returns:
- schema of this schema name.
-
-