tableConfig

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsKeywordMeta

type AsKeywordMeta struct {
	IsFunc   bool
	Name     string
	Alias    string
	DataType datatype.DataType
	CQLType  string
}

Select Query Models

type Column

type Column struct {
	Name         string
	CQLType      string
	SpannerType  string
	IsPrimaryKey bool
	PkPrecedence int64
	Metadata     message.ColumnMetadata
}

type ColumnType

type ColumnType struct {
	CQLType      string
	SpannerType  string
	IsPrimaryKey bool
}

type SelectedColumns

type SelectedColumns struct {
	FormattedColumn string
	Name            string
	IsFunc          bool
	IsAs            bool
	FuncName        string
	Alias           string
}

type TableConfig

type TableConfig struct {
	Logger          *zap.Logger
	TablesMetaData  map[string]map[string]*Column
	PkMetadataCache map[string][]Column
	KeyspaceFlatter bool
}

func (*TableConfig) GetColumnType

func (c *TableConfig) GetColumnType(tableName string, columnName string) (*ColumnType, error)

GetColumnType retrieves the column types for a specified column in a specified table. This method is a part of the TableConfig struct and is used to map column types from Cassandra (CQL) to Google Cloud Spanner.

Parameters: - tableName: A string representing the name of the table. - columnName: A string representing the name of the column within the specified table.

Returns:

  • A pointer to a ColumnType struct that contains both the CQL type and the corresponding Spanner type for the specified column.
  • An error if the function is unable to determine the corresponding Spanner type.

func (*TableConfig) GetMetadataForColumns

func (c *TableConfig) GetMetadataForColumns(tableName string, columnNames []string) ([]*message.ColumnMetadata, error)

GetMetadataForColumns retrieves metadata for specific columns in a given table. This method is a part of the TableConfig struct.

Parameters:

  • tableName: The name of the table for which column metadata is being requested.
  • columnNames(optional):Accepts nil if no columnNames provided or else A slice of strings containing the names of the columns for which metadata is required. If this slice is empty, metadata for all columns in the table will be returned.

Returns: - A slice of pointers to ColumnMetadata structs containing metadata for each requested column. - An error if the specified table is not found in the TablesMetaData.

func (*TableConfig) GetMetadataForSelectedColumns

func (c *TableConfig) GetMetadataForSelectedColumns(tableName string, columnNames []SelectedColumns, aliasMap map[string]AsKeywordMeta) ([]*message.ColumnMetadata, error)

GetMetadataForSelectedColumns simply fetching column metadata for selected columns .

Parameters:

  • tableName: The name of the table for which column metadata is being requested.
  • columnNames(optional): []SelectedColumns - Accepts nil if no columnNames provided or else A slice of strings containing the names of the columns for which metadata is required. If this slice is empty, metadata for all columns in the table will be returned.

Returns: - A slice of pointers to ColumnMetadata structs containing metadata for each requested column. - An error if the specified table is not found in the TablesMetaData.

func (*TableConfig) GetPkByTableName

func (c *TableConfig) GetPkByTableName(tableName string) ([]Column, error)

GetPkByTableName searches for and retrieves the primary keys of a specific table

Parameters:

  • tableName: A string representing the name of the table for which the metadata is requested.

Returns:

  • []Column: Array of Column details which are Primary Keys.
  • An error: Returns error if function not able to search any primary keys

Jump to

Keyboard shortcuts

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