Class 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

    Read more about object names at Snowflake here and here.

    • 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 identifier
        name - 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 identifier
        name - 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 name
        name - 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 identifier
        schema - raw schema identifier
        name - 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 identifier
        schema - schema identifier
        name - 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object