information

package
v0.0.0-...-0236cb5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

package information is used for performing schema inference.

It is used by peripheral packages to do things like create a data generator map for a table

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetColumnsQuery

func GetColumnsQuery(table string) spanner.Statement

GetColumnsQuery returns a spanner statement for fetching column information for a table

func GetIndexesQuery

func GetIndexesQuery(table string) spanner.Statement

GetIndexesQuery returns a spanner statement for fetching index information for a table

func GetTableQuery

func GetTableQuery(table string) spanner.Statement

func ListTablesQuery

func ListTablesQuery() spanner.Statement

ListTablesQuery will construct a query for fetching all tables from information_schema TODO: Support schema?

Types

type CheckConstraint

type CheckConstraint struct {
	// The name of the constraint's catalog. This column is never null, but always an empty string.
	ConstraintCatalog string `spanner:"CONSTRAINT_CATALOG"`
	// The name of the constraint's schema. An empty string if unnamed.
	ConstraintSchema string `spanner:"CONSTRAINT_SCHEMA"`
	// The name of the constraint. This column is never null. If not explicitly specified in the schema definition, a system-defined name is assigned.
	ConstraintName string `spanner:"CONSTRAINT_NAME"`
	// The expressions of the CHECK constraint. This column is never null.
	CheckClause string `spanner:"CHECK_CLAUSE"`
	// The current state of the CHECK constraint. This column is never null. The possible states are as follows:
	//   VALIDATING: Cloud Spanner is validating the existing data.
	//   COMMITTED: There is no active schema change for this constraint.
	SpannerState string `spanner:"SPANNER_STATE"`
}

CheckConstraint is a row from information_schema.check_constraints (see: https://cloud.google.com/spanner/docs/information-schema#information_schemacheck_constraints)

type CheckConstraints

type CheckConstraints []*CheckConstraint

CheckConstraints is a collection of CheckConstraint

type Column

type Column struct {
	// The name of the catalog. Always an empty string.
	TableCatalog *string `spanner:"TABLE_CATALOG"`
	// The name of the schema. An empty string if unnamed.
	TableSchema *string `spanner:"TABLE_SCHEMA"`
	// The name of the table.
	TableName *string `spanner:"TABLE_NAME"`
	// The name of the column.
	ColumnName *string `spanner:"COLUMN_NAME"`
	// The ordinal position of the column in the table, starting with a value of 1.
	OrdinalPosition int64 `spanner:"ORDINAL_POSITION"`
	// Included to satisfy the SQL standard. Always NULL.
	ColumnDefault []byte `spanner:"COLUMN_DEFAULT"`
	// Included to satisfy the SQL standard. Always NULL.
	DataType *string `spanner:"DATA_TYPE"`
	// A string that indicates whether the column is nullable. In accordance with the SQL standard, the string is either YES or NO, rather than a Boolean value.
	IsNullable *string `spanner:"IS_NULLABLE"`
	// The data type of the column.
	SpannerType *string `spanner:"SPANNER_TYPE"`
	// A string that indicates whether the column is generated. The string is either ALWAYS for a generated column or NEVER for a non-generated column.
	IsGenerated bool `spanner:"IS_GENERATED"`
	// A string representing the SQL expression of a generated column. NULL if the column is not a generated column.
	GenerationExpression *string `spanner:"GENERATION_EXPRESSION"`
	// A string that indicates whether the generated column is stored. The string is always YES for generated columns, and NULL for non-generated columns.
	IsStored *string `spanner:"IS_STORED"`
	// The current state of the column. A new stored generated column added to an existing table may go through multiple user-observable states before it is fully usable. Possible values are:
	//   WRITE_ONLY: The column is being backfilled. No read is allowed.
	// 	 COMMITTED: The column is fully usable.
	SpannerState         *string `spanner:"SPANNER_STATE"`
	IsPrimaryKey         bool    `spanner:"IS_PRIMARY_KEY"`
	AllowCommitTimestamp bool    `spanner:"ALLOW_COMMIT_TIMESTAMP"`
}

Column is a row from information_schema.columns (see: https://cloud.google.com/spanner/docs/information-schema#information_schemacolumns)

type ColumnOption

type ColumnOption struct {
	// The name of the catalog. Always an empty string.
	TableCatalog string `spanner:"TABLE_CATALOG"`
	// The name of the schema. The name is empty for the default schema and non-empty for other schemas (for example, the INFORMATION_SCHEMA itself). This column is never null.
	TableSchema string `spanner:"TABLE_SCHEMA"`
	// The name of the table.
	TableName string `spanner:"TABLE_NAME"`
	// The name of the column.
	ColumnName string `spanner:"COLUMN_NAME"`
	// A SQL identifier that uniquely identifies the option. This identifier is the key of the OPTIONS clause in DDL.
	OptionName string `spanner:"OPTION_NAME"`
	// A data type name that is the type of this option value.
	OptionType string `spanner:"OPTION_TYPE"`
	// A SQL literal describing the value of this option. The value of this column must be parsable as part of a query. The expression resulting from parsing the value must be castable to OPTION_TYPE. This column is never null.
	OptionValue string `spanner:"OPTION_VALUE"`
}

ColumnOption is a row from information_schema.column_options (see: https://cloud.google.com/spanner/docs/information-schema#information_schemacolumn_options)

type ColumnOptions

type ColumnOptions []*ColumnOption

ColumnOptions is a collection of ColumnOption

type Columns

type Columns []*Column

Columns is a collection of Collumns

type ConstraintColumnUsage

type ConstraintColumnUsage struct {
	// The name of the column table's catalog. Always an empty string.
	TableCatalog string `spanner:"TABLE_CATALOG"`
	// The name of the column table's schema. This column is never null. An empty string if unnamed.
	TableSchema string `spanner:"TABLE_SCHEMA"`
	// The name of the column's table.
	TableName string `spanner:"TABLE_NAME"`
	// The name of the column that is used by the constraint.
	ColumnName string `spanner:"COLUMN_NAME"`
	// The name of the constraint's catalog. Always an empty string.
	ConstraintCatalog string `spanner:"CONSTRAINT_CATALOG"`
	// The name of the constraint's schema. An empty string if unnamed.
	ConstraintSchema string `spanner:"CONSTRAINT_SCHEMA"`
	// The name of the constraint.
	ConstraintName string `spanner:"CONSTRAINT_NAME"`
}

ConstraintColumnUsage is a row from information_schema.constraint_column_usage (see: https://cloud.google.com/spanner/docs/information-schema#information_schemaconstraint_column_usage)

type ConstraintColumnUsages

type ConstraintColumnUsages []*ConstraintColumnUsage

ConstraintcolumnUsages is a collection of ConstraintColumnUsage

type ConstraintTableUsage

type ConstraintTableUsage struct {
	// The name of the constrained table's catalog. Always an empty string.
	TableCatalog string `spanner:"TABLE_CATALOG"`
	// The name of the constrained table's schema. An empty string if unnamed.
	TableSchema string `spanner:"TABLE_SCHEMA"`
	// The name of the constrained table.
	TableName string `spanner:"TABLE_NAME"`
	// The name of the constraint's catalog. Always an empty string.
	ConstraintCatalog string `spanner:"CONSTRAINT_CATALOG"`
	// The name of the constraint's schema. An empty string if unnamed.
	ConstraintSchema string `spanner:"CONSTRAINT_SCHEMA"`
	// The name of the constraint.
	ConstraintName string `spanner:"CONSTRAINT_NAME"`
}

ConstraintTable is a row rom information_schema.constraint_table_usage (see: https://cloud.google.com/spanner/docs/information-schema#information_schemaconstraint_table_usage)

type ConstraintTableUsages

type ConstraintTableUsages []*ConstraintTableUsage

ConstraintTableUsages is a collection of ConstraintTableUsage

type Index

type Index struct {
	// The name of the catalog. Always an empty string.
	TableCatalog string `spanner:"TABLE_CATALOG"`
	// The name of the schema. An empty string if unnamed.
	TableSchema string `spanner:"TABLE_SCHEMA"`
	// The name of the table.
	TableName string `spanner:"TABLE_NAME"`
	// The name of the index. Tables with a PRIMARY KEY specification have a pseudo-index entry generated with the name PRIMARY_KEY, which allows the fields of the primary key to be determined.
	IndexName string `spanner:"INDEX_NAME"`
	// The type of the index. The type is INDEX or PRIMARY_KEY.
	IndexType string `spanner:"INDEX_TYPE"`
	// Secondary indexes can be interleaved in a parent table, as discussed in Creating a secondary index. This column holds the name of that parent table, or NULL if the index is not interleaved.
	ParentTableName string `spanner:"PARENT_TABLE_NAME"`
	// Whether the index keys must be unique.
	IsUnique bool `spanner:"IS_UNIQUE"`
	// Whether the index includes entries with NULL values.
	IsNullFiltered bool `spanner:"IS_NULL_FILTERED"`
	// The current state of the index. Possible values and the states they represent are:
	//   PREPARE: creating empty tables for a new index.
	//   WRITE_ONLY: backfilling data for a new index.
	//   WRITE_ONLY_CLEANUP: cleaning up a new index.
	//   WRITE_ONLY_VALIDATE_UNIQUE: checking uniqueness of data in a new index.
	//   READ_WRITE: normal index operation.
	IndexState string `spanner:"INDEX_STATE"`
	// True if the index is managed by Cloud Spanner; Otherwise, False. Secondary backing indexes for foreign keys are managed by Cloud Spanner.
	SpannerIsManaged bool `spanner:"SPANNER_IS_MANAGED"`
}

Index is a row in information_schema.indexes (see: https://cloud.google.com/spanner/docs/information-schema#indexes)

type IndexColumn

type IndexColumn struct {
	// The name of the catalog. Always an empty string.
	TableCatalog string `spanner:"TABLE_CATALOG"`
	// The name of the schema. An empty string if unnamed.
	TableSchema string `spanner:"TABLE_SCHEMA"`
	// The name of the table.
	TableName string `spanner:"TABLE_NAME"`
	// The name of the index.
	IndexName string `spanner:"INDEX_NAME"`
	// The name of the column.
	ColumnName string `spanner:"COLUMN_NAME"`
	// The ordinal position of the column in the index (or primary key), starting with a value of 1. This value is NULL for non-key columns (for example, columns specified in the STORING clause of an index).
	OrdinalPosition int64 `spanner:"ORDINAL_POSITION"`
	// The ordering of the column. The value is ASC or DESC for key columns, and NULL for non-key columns (for example, columns specified in the STORING clause of an index).
	ColumnOrdering string `spanner:"COLUMN_ORDERING"`
	// A string that indicates whether the column is nullable. In accordance with the SQL standard, the string is either YES or NO, rather than a Boolean value.
	IsNullable string `spanner:"IS_NULLABLE"`
	// The data type of the column.
	SpannerType string `spanner:"SPANNER_TYPE"`
}

IndexColumn is a row in information_schema.index_columns (see: https://cloud.google.com/spanner/docs/information-schema#information_schemaindex_columns)

type IndexColumns

type IndexColumns []*IndexColumn

IndexColumns is a collection of IndexColumn

type Indexes

type Indexes []*Index

Indexes is a collection of Index

type KeyColumnUsage

type KeyColumnUsage struct {
	// The name of the constraint's catalog. Always an empty string.
	ConstraintCatalog string `spanner:"CONSTRAINT_CATALOG"`
	// The name of the constraint's schema. This column is never null. An empty string if unnamed.
	ConstraintSchema string `spanner:"CONSTRAINT_SCHEMA"`
	// The name of the constraint.
	ConstraintName string `spanner:"CONSTRAINT_NAME"`
	// The name of the constrained column's catalog. Always an empty string.
	TableCatalog string `spanner:"TABLE_CATALOG"`
	// The name of the constrained column's schema. This column is never null. An empty string if unnamed.
	TableSchema string `spanner:"TABLE_SCHEMA"`
	// The name of the constrained column's table.
	TableName string `spanner:"TABLE_NAME"`
	// The name of the column.
	ColumnName string `spanner:"COLUMN_NAME"`
	// The ordinal position of the column within the constraint's key, starting with a value of 1.
	OrdinalPosition int64 `spanner:"ORDINAL_POSITION"`
	// For FOREIGN KEYs, the ordinal position of the column within the unique constraint, starting with a value of 1. This column is null for other constraint types.
	PositionInUniqueConstraint int64 `spanner:"POSITION_IN_UNIQUE_CONSTRAINT"`
}

KeyColumnUsage is a row in information_schema.key_column_usage (see: https://cloud.google.com/spanner/docs/information-schema#information_schemakey_column_usage)

type KeyColumnUsages

type KeyColumnUsages []*KeyColumnUsage

KeyColumnUsages is a collection of KeyColumnUsage

type ReferentialConstraint

type ReferentialConstraint struct {
	// The name of the FOREIGN KEY's catalog. Always an empty string.
	ConstraintCatalog string `spanner:"CONSTRAINT_CATALOG"`
	// The name of the FOREIGN KEY's schema. An empty string if unnamed.
	ConstraintSchema string `spanner:"CONSTRAINT_SCHEMA"`
	// The name of the FOREIGN KEY.
	ConstraintName string `spanner:"CONSTRAINT_NAME"`
	// The catalog name of the PRIMARY KEY or UNIQUE constraint the FOREIGN KEY references. Always an empty string.
	UniqueConstraintCatalog string `spanner:"UNIQUE_CONSTRAINT_CATALOG"`
	// The schema name of the PRIMARY KEY or UNIQUE constraint the FOREIGN KEY references. An empty string if unnamed.
	UniqueConstraintSchema string `spanner:"UNIQUE_CONSTRAINT_SCHEMA"`
	// The name of the PRIMARY KEY or UNIQUE constraint the FOREIGN KEY references.
	UniqueConstraintName string `spanner:"UNIQUE_CONSTRAINT_NAME"`
	// Always SIMPLE.
	MatchOption string `spanner:"MATCH_OPTION"`
	// Always NO ACTION.
	UpdateRule string `spanner:"UPDATE_RULE"`
	// Always NO ACTION.
	DeleteRule string `spanner:"DELETE_RULE"`
	// The current state of the foreign key. Spanner does not begin enforcing the constraint until the foreign key's backing indexes are created and backfilled. Once the indexes are ready, Spanner begins enforcing the constraint for new transactions while it validates the existing data. Possible values and the states they represent are:
	//   BACKFILLING_INDEXES: indexes are being backfilled.
	//   VALIDATING_DATA: existing data and new writes are being validated.
	//   WAITING_FOR_COMMIT: the foreign key bulk operations have completed successfully, or none were needed, but the foreign key is still pending.
	//   COMMITTED: the schema change was committed.
	SpannerState string `spanner:"SPANNER_STATE"`
}

ReferentialConstraint is a row from information_schema.referential_constraints (see: https://cloud.google.com/spanner/docs/information-schema#referential-constraints)

type ReferentialConstraints

type ReferentialConstraints []*ReferentialConstraint

ReferentialConstraints is a collection of ReferentialConstraint

type SpannerStatistic

type SpannerStatistic struct {
	// The name of the catalog. Always an empty string.
	CatalogName string `spanner:"CATALOG_NAME"`
	// The name of the schema. The name is empty for the default schema and non-empty for other schemas (for example, the INFORMATION_SCHEMA itself). This column is never null.
	SchemaName string `spanner:"SCHEMA_NAME"`
	// The name of the statistics package.
	PackageName string `spanner:"PACKAGE_NAME"`
	// False if the statistics package is exempted from garbage collection; Otherwise, True.
	// This attribute must be set to False in order to reference the statistics package in a hint or through client API.
	AllowGC bool `spanner:"ALLOW_GC"`
}

SpannerStatistic is a row in information_schema.spanner_statistics (see https://cloud.google.com/spanner/docs/information-schema#information_schemaspanner_statistics)

type SpannerStatistics

type SpannerStatistics []*SpannerStatistic

SpannerStatistics is a collection of SpannerStatistic

type Table

type Table struct {
	// The name of the catalog. Always an empty string.
	TableCatalog *string `spanner:"TABLE_CATALOG"`
	// The name of the schema. An empty string if unnamed.
	TableSchema *string `spanner:"TABLE_SCHEMA"`
	// The name of the table or view.
	TableName *string `spanner:"TABLE_NAME"`
	// The type of the table. For tables it has the value BASE TABLE; for views it has the value VIEW.
	TableType *string `spanner:"TABLE_TYPE"`
	// The name of the parent table if this table is interleaved, or NULL.
	ParentTableName *string `spanner:"PARENT_TABLE_NAME"`
	// This is set to CASCADE or NO ACTION for interleaved tables, and NULL otherwise. See TABLE statements for more information.
	OnDeleteAction *string `spanner:"ON_DELETE_ACTION"`
	// A table can go through multiple states during creation, if bulk operations are involved. For example, when the table is created with a foreign key that requires backfilling of its indexes. Possible states are:
	//   ADDING_FOREIGN_KEY: Adding the table's foreign keys.
	//   WAITING_FOR_COMMIT: Finalizing the schema change.
	//   COMMITTED: The schema change to create the table has been committed. You cannot write to the table until the change is committed.
	SpannerState *string `spanner:"SPANNER_STATE"`
}

Table is a row in information_schema.tables (see: https://cloud.google.com/spanner/docs/information-schema#information_schematables)

type TableConstraint

type TableConstraint struct {
	// Always an emptry string.
	ConstraintCatalog string `spanner:"CONSTRAINT_CATALOG"`
	// The name of the constraint's schema. An empty string if unnamed.
	ConstraintSchema string `spanner:"CONSTRAINT_SCHEMA"`
	// The name of the constraint.
	ConstraintName string `spanner:"CONSTRAINT_NAME"`
	// The name of constrained table's catalog. Always an empty string.
	TableCatalog string `spanner:"TABLE_CATALOG"`
	// The name of constrained table's schema. An empty string if unnamed.
	TableSchema string `spanner:"TABLE_SCHEMA"`
	// The name of the constrained table.
	TableName string `spanner:"TABLE_NAME"`
	// The type of the constraint. Possible values are:
	//   PRIMARY KEY
	//   FOREIGN KEY
	//   CHECK
	//   UNIQUE
	ConstraintType string `spanner:"CONSTRAINT_TYPE"`
	// Always NO.
	IsDeferrable string `spanner:"IS_DEFERRABLE"`
	// Always NO.
	InitiallyDeferred string `spanner:"INITIALLY_DEFERRED"`
	//Always YES.
	Enforced string `spanner:"ENFORCED"`
}

TableConstraint is a row from information_schema.table_constraints (see: https://cloud.google.com/spanner/docs/information-schema#information_schematable_constraints)

type TableConstraints

type TableConstraints []*TableConstraint

TableConstraints is a collection of TableConstraint

type Tables

type Tables []*Table

Tables is a collection of tables

type View

type View struct {
	// The name of the catalog. Always an empty string.
	TableCatalog string `spanner:"TABLE_CATALOG"`
	// The name of the schema. An empty string if unnamed.
	TableSchema string `spanner:"TABLE_SCHEMA"`
	// The name of the view.
	TableName string `spanner:"TABLE_NAME"`
	// The SQL text of the query that defines the view.
	ViewDefinition string `spanner:"VIEW_DEFINITION"`
}

View is a row in information_schema.views (see: https://cloud.google.com/spanner/docs/information-schema#information_schemaviews)

type Views

type Views []*View

Views is a collection of View

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL