Class ObjectName
- java.lang.Object
-
- com.snowflake.connectors.common.object.ObjectName
-
public class ObjectName extends Object
Representation of a Snowflake object name.An
ObjectName
object can be a representation of:- an individual name identifier
- a
schema.name
object - a
db.schema.name
object - a
db..name
object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static ObjectName
from(Identifier name)
Creates a new object name instance from the provided name identifier.static ObjectName
from(Identifier schema, Identifier name)
Creates a new object name instance from the provided schema and name identifiers.static ObjectName
from(Identifier database, Identifier schema, Identifier name)
Creates a new object name instance from the provided database, schema, and name identifiers.static ObjectName
from(SchemaName schemaName, Identifier name)
Creates a new object name instance from the provided schema name and name identifier.static ObjectName
from(String schema, String name)
Creates a new object name instance from the provided raw schema and name identifiers.static ObjectName
from(String database, String schema, String name)
Creates a new object name instance from the provided raw database, schema, and name identifiers.static ObjectName
fromString(String objectName)
Creates a new object name instance from the provided raw object name (fully qualified or not).Optional<Identifier>
getDatabase()
Returns the database of this object name.Identifier
getName()
Returns the name of this object name.Optional<Identifier>
getSchema()
Returns the schema of this object name.Optional<SchemaName>
getSchemaName()
Returns the schema name of this object name.String
getValue()
Returns the object name value.Variant
getVariantValue()
Returns the object name value as a Snowpark Variant object.int
hashCode()
boolean
isFullyQualified()
Returns whether this object name is fully qualified.static boolean
isValid(String objectName)
Returns whether the provided String is a valid object name.String
toString()
-
-
-
Method Detail
-
fromString
public static ObjectName fromString(String objectName)
Creates a new object name instance from the provided raw object name (fully qualified or not).- Parameters:
objectName
- raw object name- Returns:
- new object name instance
- Throws:
InvalidObjectNameException
- if the provided String is not a valid Snowflake object name
-
from
public static ObjectName from(Identifier name)
Creates a new object name instance from the provided name identifier.- Parameters:
name
- name identifier- Returns:
- new object name instance
- Throws:
InvalidIdentifierException
- if the provided name identifier is null
-
from
public static ObjectName from(String schema, String name)
Creates a new object name instance from the provided raw schema and name identifiers.- Parameters:
schema
- raw schema identifiername
- raw object identifier- Returns:
- new object name instance
- Throws:
InvalidIdentifierException
- if the provided schema or name is not a valid Snowflake identifier
-
from
public static ObjectName from(Identifier schema, Identifier name)
Creates a new object name instance from the provided schema and name identifiers.- Parameters:
schema
- schema identifiername
- name identifier- Returns:
- new object name instance
- Throws:
InvalidIdentifierException
- if the provided name identifier is null
-
from
public static ObjectName from(SchemaName schemaName, Identifier name)
Creates a new object name instance from the provided schema name and name identifier.- Parameters:
schemaName
- schema namename
- name identifier- Returns:
- new object name instance
- Throws:
InvalidIdentifierException
- if the provided name identifier is null
-
from
public static ObjectName from(String database, String schema, String name)
Creates a new object name instance from the provided raw database, schema, and name identifiers.- Parameters:
database
- raw database identifierschema
- raw schema identifiername
- raw name identifier- Returns:
- new object name instance
- Throws:
InvalidIdentifierException
- if the provided database, schema, or name is not a valid Snowflake identifier
-
from
public static ObjectName from(Identifier database, Identifier schema, Identifier name)
Creates a new object name instance from the provided database, schema, and name identifiers.- Parameters:
database
- database identifierschema
- schema identifiername
- name identifier- Returns:
- new object name instance
- Throws:
InvalidIdentifierException
- if the provided name identifier is null
-
isValid
public static boolean isValid(String objectName)
Returns whether the provided String is a valid object name.- Parameters:
objectName
- raw object name- Returns:
- whether the provided String is a valid object name
-
getValue
public String getValue()
Returns the object 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, a database-less name, a double-dot notated name, or a simple unqualified object name.
The individual identifiers will be converted to String using
Identifier.getValue()
. They may be quoted or unquoted.- Returns:
- SQL-friendly object name
-
getVariantValue
public Variant getVariantValue()
Returns the object name value as a Snowpark Variant object.- Returns:
- object name value in a Variant
-
isFullyQualified
public boolean isFullyQualified()
Returns whether this object name is fully qualified.- Returns:
- whether this object name is fully qualified
-
getDatabase
public Optional<Identifier> getDatabase()
Returns the database of this object name.- Returns:
- database of this object name.
-
getSchema
public Optional<Identifier> getSchema()
Returns the schema of this object name.- Returns:
- schema of this object name.
-
getSchemaName
public Optional<SchemaName> getSchemaName()
Returns the schema name of this object name.- Returns:
- schema name of this object name.
-
getName
public Identifier getName()
Returns the name of this object name.- Returns:
- name of this object name.
-
-