// FetchTables fetches all table information in the database from Spanner.
FetchTables fetches all table information in the database from Spanner.
// FetchTables fetches all table information in the database from Spanner .
func FetchTables(ctx context.Context, txn *spanner.ReadOnlyTransaction) (*TableIterator, error) {
	stmt := spanner.NewStatement(`
SELECT t.TABLE_NAME as table, t.PARENT_TABLE_NAME as parent, c.columns
FROM INFORMATION_SCHEMA.TABLES as t
JOIN (
    SELECT c.TABLE_NAME as table, ARRAY_AGG(c.COLUMN_NAME) as columns
    FROM INFORMATION_SCHEMA.COLUMNS AS c
    WHERE c.TABLE_CATALOG = '' AND c.TABLE_SCHEMA = ''
    GROUP BY c.TABLE_NAME
) as c
ON t.TABLE_NAME = c.table
WHERE t.TABLE_CATALOG = '' AND t.TABLE_SCHEMA = '' AND t.TABLE_TYPE = 'BASE TABLE'
ORDER BY t.TABLE_NAME ASC
`)
	var rows []tableRow
	opts := spanner.QueryOptions{Priority: sppb.RequestOptions_PRIORITY_LOW}
	if err := txn.QueryWithOptions(ctx, stmt, opts).Do(func(r *spanner.Row) error {
		var tableName, parentTableName string
		var columns []string
		var parentTableNamePtr *string 
		if err := r.ColumnByName("table", &tableName); err != nil {
			return err
		}
		if err := r.ColumnByName("parent", &parentTableNamePtr); err != nil {
			return err
		}
		if parentTableNamePtr != nil {
			parentTableName = *parentTableNamePtr
		}
		if err := r.ColumnByName("columns", &columns); err != nil {
			return err
		}
		rows = append(rows, tableRow{
			name:       tableName,
			columns:    columns,
			parentName: parentTableName,
		})
		return nil
	}); err != nil {
		return nil, err
	}
	tables := findChildTables(rows, "") 
	return &TableIterator{tables}, nil
}
func FetchTables ( ctx context . Context , txn * spanner . ReadOnlyTransaction ) ( * TableIterator , error ) { stmt := spanner . NewStatement ( `
SELECT t.TABLE_NAME as table, t.PARENT_TABLE_NAME as parent, c.columns
FROM INFORMATION_SCHEMA.TABLES as t
JOIN (
    SELECT c.TABLE_NAME as table, ARRAY_AGG(c.COLUMN_NAME) as columns
    FROM INFORMATION_SCHEMA.COLUMNS AS c
    WHERE c.TABLE_CATALOG = '' AND c.TABLE_SCHEMA = ''
    GROUP BY c.TABLE_NAME
) as c
ON t.TABLE_NAME = c.table
WHERE t.TABLE_CATALOG = '' AND t.TABLE_SCHEMA = '' AND t.TABLE_TYPE = 'BASE TABLE'
ORDER BY t.TABLE_NAME ASC
` ) var rows [ ] tableRow opts := spanner . QueryOptions { Priority : sppb . RequestOptions_PRIORITY_LOW } if err := txn . QueryWithOptions ( ctx , stmt , opts ) . Do ( func ( r * spanner . Row ) error { var tableName , parentTableName string var columns [ ] string var parentTableNamePtr * string if err := r . ColumnByName ( " " , & tableName ) ; err != nil { return err } if err := r . ColumnByName ( " " , & parentTableNamePtr ) ; err != nil { return err } if parentTableNamePtr != nil { parentTableName = * parentTableNamePtr } if err := r . ColumnByName ( " " , & columns ) ; err != nil { return err } rows = append ( rows , tableRow { name : tableName , columns : columns , parentName : parentTableName , } ) return nil } ) ; err != nil { return nil , err } tables := findChildTables ( rows , " " ) return & TableIterator { tables } , nil }
FetchTables fetches all table information in the database from Spanner.
FetchTables fetches all table information in the database from Spanner .
// SQL for fetching table name, parent, and columns // nullable // root