Class SpannerObjectName

java.lang.Object
io.github.flink.gcp.connector.spanner.SpannerObjectName

@Internal public final class SpannerObjectName extends Object
A table's schema and name as one Flink object name: the default schema's tables unqualified, a named schema's as schema.table, each part in the dialect's canonical quoting.

The name is Flink's: an ObjectPath holds a database name and an object name, and this class is the object name the spanner catalog gives a table. It converts, in both directions, between that object name and the native schema and table names INFORMATION_SCHEMA reports. It is not SpannerTableName, which decodes the connector's named-schema and table options of one configured table into the names the data APIs take; the catalog emits those options through encodePart(String, Dialect).

Spanner addresses a table by database, schema and table, while a Flink catalog has two levels below its name, so the schema travels inside the Flink object name, as the JDBC connector's PostgreSQL catalog does. format(String, String, Dialect) and parse(String, Dialect) are inverses: every name format produces parses back to the same native schema and table, which is what lets a name SHOW TABLES printed resolve through getTable. A part is quoted when its bare spelling would decode to a different name: a PostgreSQL name with an upper-case letter, which an unquoted part folds, or any name outside the dialect's plain identifier grammar.

  • Method Details

    • of

      public static SpannerObjectName of(String schema, String table)
      Creates a name from native schema and table names, as INFORMATION_SCHEMA spells them.
      Parameters:
      schema - the native schema name; Dialect.getDefaultSchema() for the default one
      table - the native table name
      Returns:
      the name
    • format

      public static String format(String schema, String table, com.google.cloud.spanner.Dialect dialect)
      Renders a table as a Flink object name.
      Parameters:
      schema - the native schema name, as INFORMATION_SCHEMA spells it
      table - the native table name
      dialect - the database's dialect
      Returns:
      the table alone for the default schema, otherwise schema.table
    • encodePart

      public static String encodePart(String nativeName, com.google.cloud.spanner.Dialect dialect)
      Renders one native name as a component in canonical quoting, the form the connector's schema and table options decode.
      Parameters:
      nativeName - the native name
      dialect - the database's dialect
      Returns:
      the name, quoted where its bare spelling would decode to a different one
    • parse

      public static Optional<SpannerObjectName> parse(String objectName, com.google.cloud.spanner.Dialect dialect)
      Parses a Flink object name into a native schema and table.
      Parameters:
      objectName - the name as Flink passes it, after its own identifier quoting is removed
      dialect - the database's dialect
      Returns:
      the name, or empty when it is not one or two parts in canonical quoting, which no table can be named
    • schema

      public String schema()
      Returns the native schema name; the dialect's default schema for an unqualified name.
      Returns:
      the schema
    • table

      public String table()
      Returns the native table name.
      Returns:
      the table
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object